'select', 'options' => $fieldData['options'] ?? [], 'empty' => $fieldData['empty'] ?? false, 'value' => $fieldData['value'] ?? null, 'multiple' => $fieldData['multiple'] ?? false, 'disabled' => $fieldData['disabled'] ?? false, 'class' => ($fieldData['class'] ?? '') . ' formDropdown form-select', 'default' => $fieldData['default'] ?? '', ]; if (!empty($fieldData['field'])) { // used for multi meta-field form $controlParams['field'] = $fieldData['field']; } if (!empty($fieldData['label'])) { $controlParams['label'] = $fieldData['label']; } if ($controlParams['options'] instanceof \Cake\ORM\Query) { $controlParams['options'] = $controlParams['options']->all()->toList(); } if (!empty($fieldData['select2'])) { $fieldData['select2'] = $fieldData['select2'] === true ? [] : $fieldData['select2']; $controlParams['class'] .= ' select2-input'; } $controlParams['class'] .= ' dropdown-custom-value' . "-$seed"; if (in_array('_custom', array_keys($controlParams['options']))) { $customInputValue = $this->Form->getSourceValue($fieldData['field']); if (!in_array($customInputValue, $controlParams['options'])) { $controlParams['options'] = array_map(function ($option) { if (is_array($option) && $option['value'] == '_custom') { $option[] = 'selected'; } return $option; }, $controlParams['options']); } else { $customInputValue = ''; } $adaptedField = $fieldData['field'] . '_custom'; $controlParams['templates']['formGroup'] = sprintf( '
{{input}}{{error}}%s
', sprintf('', h($adaptedField), h($customInputValue)) ); } echo $this->FormFieldMassage->prepareFormElement($this->Form, $controlParams, $fieldData); ?>