'
{{content}}
', 'inputContainerError' => '
{{content}}
', 'formGroup' => '
{{input}}{{error}}
', 'error' => '
{{content}}
', 'errorList' => '', 'errorItem' => '
  • {{text}}
  • ', ]; $this->Form->setTemplates($default_template); $backupTemplates = $this->Form->getTemplates(); $fieldsHtml = ''; foreach ($metaTemplate->meta_template_fields as $metaTemplateField) { $metaTemplateField->label = Inflector::humanize($metaTemplateField->field); if (!empty($metaTemplateField->metaFields)) { if (!empty($metaTemplateField->multiple)) { $fieldsHtml .= $this->element( 'genericElements/Form/multiFieldScaffold', [ 'metaFieldsEntities' => $metaTemplateField->metaFields, 'metaTemplateField' => $metaTemplateField, 'multiple' => !empty($metaTemplateField->multiple), 'form' => $this->Form, ] ); } else { $metaField = reset($metaTemplateField->metaFields); $fieldData = [ 'label' => $metaTemplateField->label, 'type' => $metaTemplateField->formType, ]; if (!empty($metaTemplateField->formOptions)) { $fieldData = array_merge_recursive($fieldData, $metaTemplateField->formOptions); } if (isset($metaField->id)) { $fieldData['field'] = sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.%s.value', $metaField->meta_template_id, $metaField->meta_template_field_id, $metaField->id); } 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)); } $this->Form->setTemplates($backupTemplates); $fieldsHtml .= $this->element( 'genericElements/Form/fieldScaffold', [ 'fieldData' => $fieldData, 'metaTemplateField' => $metaTemplateField, 'form' => $this->Form ] ); } } else { if (!empty($metaTemplateField->multiple)) { $fieldsHtml .= $this->element( 'genericElements/Form/multiFieldScaffold', [ 'metaFieldsEntities' => [], 'metaTemplateField' => $metaTemplateField, 'multiple' => !empty($metaTemplateField->multiple), 'form' => $this->Form, ] ); } else { $this->Form->setTemplates($backupTemplates); $fieldData = [ 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new.0', $metaTemplateField->meta_template_id, $metaTemplateField->id), 'label' => $metaTemplateField->label, 'type' => $metaTemplateField->formType, ]; if (!empty($metaTemplateField->formOptions)) { $fieldData = array_merge_recursive($fieldData, $metaTemplateField->formOptions); } $fieldsHtml .= $this->element( 'genericElements/Form/fieldScaffold', [ 'fieldData' => $fieldData, 'form' => $this->Form ] ); } } } $fieldContainer = $this->Bootstrap->node('div', [ 'class' => [], ], $fieldsHtml); echo $fieldContainer;