From 2aad4c99a5937f76ae07f4f3cc947f85d7f102ec Mon Sep 17 00:00:00 2001 From: "M.A. Peene" Date: Mon, 19 Jun 2023 14:37:41 +0200 Subject: [PATCH] Fix: combination render (#31) * fix: render form fields with uppercase in type * fix: use field->GetCombinationChildren to (default) render combination fields * fix: lint --- .../forms/fields/combination.blade.php | 36 ++++++------------- src/Models/Forms/Field.php | 6 ++-- src/Services/Editor/FieldsProperties.php | 2 +- .../Forms/Fields/AbstractFieldComponent.php | 7 ++-- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/resources/views/siteboss/forms/fields/combination.blade.php b/resources/views/siteboss/forms/fields/combination.blade.php index c3f2678a..6a827fbe 100644 --- a/resources/views/siteboss/forms/fields/combination.blade.php +++ b/resources/views/siteboss/forms/fields/combination.blade.php @@ -1,26 +1,10 @@ -
-
- {% for item in item.fields %} - {{ include(item.type|lower ~ '.html', {label: item.label, properties: item.properties, id: item.id }) }} - {% endfor %} -
-
- -{% if item.triggerId != '' %} - -{% endif %} +
+ @foreach ($field->GetChildrenOfCombination($field->form_id, $field->id) as $childfield) +
+ +
+ @endforeach +
\ No newline at end of file diff --git a/src/Models/Forms/Field.php b/src/Models/Forms/Field.php index 74a8f38e..48c77bc0 100644 --- a/src/Models/Forms/Field.php +++ b/src/Models/Forms/Field.php @@ -2,6 +2,7 @@ namespace NotFound\Framework\Models\Forms; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\SoftDeletes; use NotFound\Framework\Models\BaseModel; @@ -163,7 +164,7 @@ public function getWithChildren(int $formId, int $combinationId = null) return $returnArray; } - public function GetChildrenOfCombination(int $formId, int $combinationId): array + public function GetChildrenOfCombination(int $formId, int $combinationId): Collection { $fieldQuery = $this ->where('form_id', $formId); @@ -174,8 +175,7 @@ public function GetChildrenOfCombination(int $formId, int $combinationId): array return $fieldQuery ->orderBy('order') - ->get() - ->toArray(); + ->get(); } private function setParentRecursive(&$fields, $parentId, $fieldToSet) diff --git a/src/Services/Editor/FieldsProperties.php b/src/Services/Editor/FieldsProperties.php index 3bd1203d..eedf0aea 100644 --- a/src/Services/Editor/FieldsProperties.php +++ b/src/Services/Editor/FieldsProperties.php @@ -150,7 +150,7 @@ private function addLayoutFields(array $properties, LayoutForm &$form) // $checkboxField->setValue(true); // } else { $checkboxField->setValue(false); - // } + // } } else { $checkboxField->setValue($value ?? false); } diff --git a/src/View/Components/Forms/Fields/AbstractFieldComponent.php b/src/View/Components/Forms/Fields/AbstractFieldComponent.php index 23f9e331..8b00ebcc 100644 --- a/src/View/Components/Forms/Fields/AbstractFieldComponent.php +++ b/src/View/Components/Forms/Fields/AbstractFieldComponent.php @@ -14,11 +14,12 @@ public function __construct( public function render() { - if (view()->exists('siteboss.forms.fields.'.$this->field->type)) { - return 'siteboss.forms.fields.'.$this->field->type; + $typeFile = strtolower($this->field->type); + if (view()->exists('siteboss.forms.fields.'.$typeFile)) { + return 'siteboss.forms.fields.'.$typeFile; } - return view('siteboss::siteboss.forms.fields.'.$this->field->type); + return view('siteboss::siteboss.forms.fields.'.$typeFile); } public function colClasses(): string