From a4230fb4b8acdd0456a3d5bf4fa6bc514366021c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Wed, 25 Oct 2023 14:15:51 +0200 Subject: [PATCH] wip --- resources/views/fields/fieldset.blade.php | 2 +- src/Fields/Fieldset.php | 14 ++++---------- src/Fields/Meta.php | 9 ++++++++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/resources/views/fields/fieldset.blade.php b/resources/views/fields/fieldset.blade.php index 04005f6ca..9e70d8e59 100644 --- a/resources/views/fields/fieldset.blade.php +++ b/resources/views/fields/fieldset.blade.php @@ -1,6 +1,6 @@
{{ $label }} @foreach($fields as $field) - {!! $field->render() !!} + @include($field['template'], $field) @endforeach
diff --git a/src/Fields/Fieldset.php b/src/Fields/Fieldset.php index 1a386a9b3..b5f37b0c1 100644 --- a/src/Fields/Fieldset.php +++ b/src/Fields/Fieldset.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Routing\Router; -use Illuminate\Support\Facades\App; class Fieldset extends Field { @@ -78,16 +77,11 @@ public function invalid(Request $request): bool /** * {@inheritdoc} */ - public function toArray(): array + public function toFormComponent(Request $request, Model $model): array { - return array_merge( - parent::toArray(), - App::call(function (Request $request): array { - return [ - 'fields' => $this->resolveFields($request)->all(), - ]; - }) - ); + return array_merge(parent::toFormComponent($request, $model), [ + 'fields' => $this->resolveFields($request)->mapToFormComponents($request, $model), + ]); } /** diff --git a/src/Fields/Meta.php b/src/Fields/Meta.php index eb00ac87f..4e39ac09b 100644 --- a/src/Fields/Meta.php +++ b/src/Fields/Meta.php @@ -3,7 +3,6 @@ namespace Cone\Root\Fields; use Closure; -use Illuminate\Contracts\View\View; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphOne as EloquentRelation; @@ -250,6 +249,14 @@ public function toArray(): array return $this->field->toArray(); } + /** + * {@inheritdoc} + */ + public function toFormComponent(Request $request, Model $model): array + { + return $this->field->toFormComponent($request, $model); + } + /** * {@inheritdoc} */