From d43e7c6c222ada4819a18807a8f8740336072b73 Mon Sep 17 00:00:00 2001 From: iglocska Date: Wed, 9 Nov 2022 14:00:18 +0100 Subject: [PATCH] new: [generic form] added checkbox option for boolean fields in metatemplates --- templates/element/genericElements/Form/genericForm.php | 3 +++ templates/element/genericElements/Form/metaTemplateForm.php | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/templates/element/genericElements/Form/genericForm.php b/templates/element/genericElements/Form/genericForm.php index 1a2bc58..7dafa18 100644 --- a/templates/element/genericElements/Form/genericForm.php +++ b/templates/element/genericElements/Form/genericForm.php @@ -112,6 +112,7 @@ echo $this->Bootstrap->modal([ 'title' => empty($data['title']) ? sprintf('%s %s', $actionName, $modelName) : h($data['title']), 'bodyHtml' => $this->element('genericElements/Form/formLayouts/formRaw', [ + 'data' => $data, 'formCreate' => $formCreate, 'ajaxFlashMessage' => $ajaxFlashMessage, 'fieldsString' => $fieldsString, @@ -124,6 +125,7 @@ ]); } else if (!empty($raw)) { echo $this->element('genericElements/Form/formLayouts/formDefault', [ + 'data' => $data, 'actionName' => $actionName, 'modelName' => $modelName, 'submitButtonData' => $submitButtonData, @@ -135,6 +137,7 @@ ]); } else { echo $this->element('genericElements/Form/formLayouts/formDefault', [ + 'data' => $data, 'actionName' => $actionName, 'modelName' => $modelName, 'submitButtonData' => $submitButtonData, diff --git a/templates/element/genericElements/Form/metaTemplateForm.php b/templates/element/genericElements/Form/metaTemplateForm.php index 0a4d934..c644a72 100644 --- a/templates/element/genericElements/Form/metaTemplateForm.php +++ b/templates/element/genericElements/Form/metaTemplateForm.php @@ -37,6 +37,9 @@ 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', @@ -64,6 +67,9 @@ foreach ($metaTemplate->meta_template_fields as $metaTemplateField) { 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new.0', $metaTemplateField->meta_template_id, $metaTemplateField->id), 'label' => $metaTemplateField->label, ]; + if ($metaTemplateField->type === 'boolean') { + $fieldData['type'] = 'checkbox'; + } $fieldsHtml .= $this->element( 'genericElements/Form/fieldScaffold', [