Skip to content

Commit e0bd4d6

Browse files
committed
Limit to one domtab per tab
1 parent c42e0af commit e0bd4d6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

inc/container.class.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,21 @@ function prepareInputForAdd($input) {
249249
}
250250
}
251251

252+
if ($input['type'] === "domtab") {
253+
//check for already exist domtab container with this itemtype on this tab
254+
$found = $this->find("`type`='domtab' AND `subtype`='{$input['subtype']}'");
255+
if (count($found) > 0) {
256+
foreach(array_column( $found, 'itemtypes' ) as $founditemtypes ) {
257+
foreach( json_decode( $founditemtypes ) as $founditemtype ) {
258+
if( in_array( $founditemtype, $input['itemtypes'] ) ) {
259+
Session::AddMessageAfterRedirect(__("You cannot add several blocks with type 'Insertion in the form of a specific tab' on same object tab", "fields"), false, ERROR);
260+
return false;
261+
}
262+
}
263+
}
264+
}
265+
}
266+
252267
//construct field name by processing label (remove non alphanumeric char and any trailing s)
253268
$input['name'] = strtolower(preg_replace("/[^\da-z]/i", "", preg_replace('/s*$/', '', $input['label'])));
254269
// if empty, uses a random number

0 commit comments

Comments
 (0)