fix: [elements:dropdownField] Always attach select2 to the body
parent
db19afd9ac
commit
5b07c57037
|
@ -10,7 +10,6 @@ echo $this->element('genericElements/Form/genericForm', [
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'select2' => true,
|
'select2' => true,
|
||||||
'label' => __('Members'),
|
'label' => __('Members'),
|
||||||
'class' => 'select2-input',
|
|
||||||
'options' => $dropdownData['individuals']
|
'options' => $dropdownData['individuals']
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
|
@ -19,7 +19,9 @@ if (!empty($fieldData['label'])) {
|
||||||
if ($controlParams['options'] instanceof \Cake\ORM\Query) {
|
if ($controlParams['options'] instanceof \Cake\ORM\Query) {
|
||||||
$controlParams['options'] = $controlParams['options']->all()->toList();
|
$controlParams['options'] = $controlParams['options']->all()->toList();
|
||||||
}
|
}
|
||||||
if (!empty($fieldData['select2'])) {
|
$initSelect2 = false;
|
||||||
|
if (isset($fieldData['select2']) && $fieldData['select2'] == true) {
|
||||||
|
$initSelect2 = true;
|
||||||
$fieldData['select2'] = $fieldData['select2'] === true ? [] : $fieldData['select2'];
|
$fieldData['select2'] = $fieldData['select2'] === true ? [] : $fieldData['select2'];
|
||||||
$controlParams['class'] .= ' select2-input';
|
$controlParams['class'] .= ' select2-input';
|
||||||
}
|
}
|
||||||
|
@ -53,8 +55,9 @@ echo $this->FormFieldMassage->prepareFormElement($this->Form, $controlParams, $f
|
||||||
$select.attr('onclick', 'toggleFreetextSelectField(this)')
|
$select.attr('onclick', 'toggleFreetextSelectField(this)')
|
||||||
$select.parent().find('input.custom-value').attr('oninput', 'updateAssociatedSelect(this)')
|
$select.parent().find('input.custom-value').attr('oninput', 'updateAssociatedSelect(this)')
|
||||||
updateAssociatedSelect($select.parent().find('input.custom-value')[0])
|
updateAssociatedSelect($select.parent().find('input.custom-value')[0])
|
||||||
<?php if (!empty($fieldData['select2'])) : ?>
|
<?php if ($initSelect2) : ?>
|
||||||
let $container = $select.closest('.modal-dialog')
|
// let $container = $select.closest('.modal-dialog .modal-body')
|
||||||
|
let $container = []
|
||||||
if ($container.length == 0) {
|
if ($container.length == 0) {
|
||||||
$container = $(document.body)
|
$container = $(document.body)
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,14 +155,5 @@
|
||||||
$('.formDropdown').on('change', function() {
|
$('.formDropdown').on('change', function() {
|
||||||
executeStateDependencyChecks('#' + this.id);
|
executeStateDependencyChecks('#' + this.id);
|
||||||
})
|
})
|
||||||
<?php if (!empty($initSelect2)): ?>
|
|
||||||
<?php
|
|
||||||
$dropdownParent = !empty($seedModal) ? sprintf("$('.modal-dialog.%s .modal-body')", $seedModal) : "$(document.body)";
|
|
||||||
?>
|
|
||||||
$('select.select2-input').select2({
|
|
||||||
dropdownParent: <?= $dropdownParent ?>,
|
|
||||||
width: '100%',
|
|
||||||
})
|
|
||||||
<?php endif; ?>
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
|
@ -94,7 +94,7 @@ input[type="checkbox"]:disabled.change-cursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container {
|
.select2-container {
|
||||||
z-index: 900;
|
z-index: 1060;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--bootstrap-5 {
|
.select2-container--bootstrap-5 {
|
||||||
|
|
Loading…
Reference in New Issue