Skip to content

Commit

Permalink
Fix: combination render (#31)
Browse files Browse the repository at this point in the history
* fix: render form fields with uppercase in type

* fix: use field->GetCombinationChildren to (default) render combination fields

* fix: lint
  • Loading branch information
MAPCMC committed Jun 19, 2023
1 parent f2415f6 commit 2aad4c9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 33 deletions.
36 changes: 10 additions & 26 deletions resources/views/siteboss/forms/fields/combination.blade.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
<div class="col-sm-12">
<div class="row">
{% for item in item.fields %}
{{ include(item.type|lower ~ '.html', {label: item.label, properties: item.properties, id: item.id }) }}
{% endfor %}
</div>
</div>

{% if item.triggerId != '' %}
<script>
$(document).ready(function() {
$("[name='{{ item.triggerId }}']" ).change(function (e){
thisCombo = $("#{{ item.id }}");
if(e.target.value == '{{ item.triggerValue }}') {
thisCombo.show();
} else {
thisCombo.hide();
//thisCombo.find('input').val('');
//thisCombo.find('textarea').val('');
//thisCombo.find("input:checked[type='radio']").prop('checked', false);
//thisCombo.find("input:checked[type='checkbox']").prop('checked', false);
}
});
})
</script>
{% endif %}
<div class="row">
@foreach ($field->GetChildrenOfCombination($field->form_id, $field->id) as $childfield)
<div>
<x-dynamic-component
:component="$childfield->getBladeComponent()"
:field="$childfield"
/>
</div>
@endforeach
</div>
6 changes: 3 additions & 3 deletions src/Models/Forms/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace NotFound\Framework\Models\Forms;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\SoftDeletes;
use NotFound\Framework\Models\BaseModel;

Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/FieldsProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function addLayoutFields(array $properties, LayoutForm &$form)
// $checkboxField->setValue(true);
// } else {
$checkboxField->setValue(false);
// }
// }
} else {
$checkboxField->setValue($value ?? false);
}
Expand Down
7 changes: 4 additions & 3 deletions src/View/Components/Forms/Fields/AbstractFieldComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2aad4c9

Please sign in to comment.