chg: [metaTemplateField] More generic way to specify form type
parent
b6fdf37d54
commit
84069cfe40
|
@ -14,6 +14,8 @@ class MetaTemplateField extends AppModel
|
|||
$formType = 'text';
|
||||
if (!empty($this->sane_default) || !empty($this->values_list)) {
|
||||
$formType = 'dropdown';
|
||||
} else if ($this->type === 'boolean') {
|
||||
$formType = 'checkbox';
|
||||
}
|
||||
return $formType;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
|||
'label' => $metaTemplateField->label,
|
||||
'type' => $metaTemplateField->formType,
|
||||
];
|
||||
if ($metaTemplateField->formType === 'dropdown') {
|
||||
if (!empty($metaTemplateField->formOptions)) {
|
||||
$fieldData = array_merge_recursive($fieldData, $metaTemplateField->formOptions);
|
||||
}
|
||||
if (isset($metaField->id)) {
|
||||
|
@ -41,9 +41,6 @@ foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
|||
} else {
|
||||
$fieldData['field'] = sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.%s.value', $metaField->meta_template_id, $metaField->meta_template_field_id, array_key_first($metaTemplateField->metaFields));
|
||||
}
|
||||
if ($metaTemplateField->type === 'boolean') {
|
||||
$fieldData['type'] = 'checkbox';
|
||||
}
|
||||
$this->Form->setTemplates($backupTemplates);
|
||||
$fieldsHtml .= $this->element(
|
||||
'genericElements/Form/fieldScaffold',
|
||||
|
@ -72,12 +69,9 @@ foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
|||
'label' => $metaTemplateField->label,
|
||||
'type' => $metaTemplateField->formType,
|
||||
];
|
||||
if ($metaTemplateField->formType === 'dropdown') {
|
||||
if (!empty($metaTemplateField->formOptions)) {
|
||||
$fieldData = array_merge_recursive($fieldData, $metaTemplateField->formOptions);
|
||||
}
|
||||
// if ($metaTemplateField->type === 'boolean') {
|
||||
// $fieldData['type'] = 'checkbox';
|
||||
// }
|
||||
$fieldsHtml .= $this->element(
|
||||
'genericElements/Form/fieldScaffold',
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue