'
{{content}}
', 'inputContainerError' => '
{{content}}
', 'formGroup' => '
{{input}}{{error}}
', ]; $form->setTemplates($default_template); $fieldsHtml = ''; $labelPrintedOnce = false; $newMetaFields = []; $newFieldIndex = 0; // $newMetaFieldPrinted = false; // debug($entity); // debug($entity->getErrors()); if (!empty($metaFieldsEntities)) { foreach ($metaFieldsEntities as $i => $metaFieldsEntity) { $metaFieldsEntity->label = Inflector::humanize($metaFieldsEntity->field); $fieldData = [ 'label' => $metaFieldsEntity->label, 'field' => sprintf( 'MetaTemplates.%s.meta_template_fields.%s.metaFields.%s.value', $metaFieldsEntity->meta_template_id, $metaFieldsEntity->meta_template_field_id, $metaFieldsEntity->id ), ]; if($metaFieldsEntity->isNew()) { $fieldData['field'] = sprintf( 'MetaTemplates.%s.meta_template_fields.%s.metaFields.%s.value', $metaFieldsEntity->meta_template_id, $metaFieldsEntity->meta_template_field_id, $i ); $fieldData['class'] = 'new-metafield'; // $fieldData['field'] = sprintf( // 'MetaTemplates.%s.meta_template_fields.%s.metaFields.new.%s', // $metaFieldsEntity->meta_template_id, // $metaFieldsEntity->meta_template_field_id, // $newFieldIndex // ); // $fieldData['class'] = 'new-metafield'; // $newMetaFieldPrinted = true; // $newFieldIndex += 1; } if ($labelPrintedOnce) { // Only the first input can have a label $fieldData['label'] = false; } $labelPrintedOnce = true; $fieldsHtml .= $this->element( 'genericElements/Form/fieldScaffold', [ 'fieldData' => $fieldData, 'form' => $form ] ); } } if (!empty($metaTemplateField) && !empty($multiple)) { // Add multiple field button $metaTemplateField->label = Inflector::humanize($metaTemplateField->field); $emptyMetaFieldInput = ''; if (empty($metaFieldsEntities)) { // $emptyMetaFieldInput = $this->element( // 'genericElements/Form/fieldScaffold', // [ // 'fieldData' => [ // 'label' => $metaTemplateField->label, // 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new.0', $metaTemplateField->meta_template_id, $metaTemplateField->id), // 'class' => 'new-metafield', // ], // 'form' => $form, // ] // ); } $emptyInputForSecurityComponent = $this->element( 'genericElements/Form/fieldScaffold', [ 'fieldData' => [ 'label' => false, 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new[]', $metaTemplateField->meta_template_id, $metaTemplateField->id), 'value' => '', ], 'form' => $form, ] ); // $emptyInputForSecurityComponent = ''; // if (!$newMetaFieldPrinted) { // $emptyInputForSecurityComponent = $this->element( // 'genericElements/Form/fieldScaffold', // [ // 'fieldData' => [ // 'label' => false, // 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new[]', $metaTemplateField->meta_template_id, $metaTemplateField->id), // ], // 'form' => $form, // ] // ); // } $multiFieldButtonHtml = sprintf( '
%s
', $this->element( 'genericElements/Form/multiFieldButton', [ 'metaTemplateFieldName' => $metaTemplateField->field, ] ) ); // $fieldsHtml .= $emptyMetaFieldInput; $fieldsHtml .= sprintf('
%s
', $emptyInputForSecurityComponent); $fieldsHtml .= $multiFieldButtonHtml; } ?>