Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Oct 25, 2023
1 parent 01703a1 commit a4230fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion resources/views/fields/fieldset.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<fieldset>
<legend>{{ $label }}</legend>
@foreach($fields as $field)
{!! $field->render() !!}
@include($field['template'], $field)
@endforeach
</fieldset>
14 changes: 4 additions & 10 deletions src/Fields/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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),
]);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/Fields/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}
*/
Expand Down

0 comments on commit a4230fb

Please sign in to comment.