Skip to content

Commit

Permalink
fix: StackFields
Browse files Browse the repository at this point in the history
Callback with updateOnPreview fields
  • Loading branch information
lee-to committed Nov 30, 2024
1 parent c55be83 commit c2fe781
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use MoonShine\Laravel\Enums\Ability;
use MoonShine\Laravel\Enums\Action;
use MoonShine\Laravel\Http\Requests\MoonShineFormRequest;
use MoonShine\Laravel\TypeCasts\ModelDataWrapper;
use MoonShine\UI\Components\FormBuilder;
use MoonShine\UI\Contracts\FieldsWrapperContract;
use Throwable;

final class UpdateColumnFormRequest extends MoonShineFormRequest
Expand Down Expand Up @@ -39,10 +42,24 @@ public function authorize(): bool
*/
public function getField(): ?FieldContract
{
return $this->getResource()
?->getIndexFields()
?->withoutWrappers()
?->findByColumn(
$resource = $this->getResource();

if(is_null($resource)) {
return null;
}

$data = $resource->getCastedData();

if(is_null($data)) {
return null;
}

$fields = $resource->getIndexFields();
$fields->each(fn(FieldContract $field) => $field instanceof FieldsWrapperContract ? $field->fillData($data) : $field);

return $fields
->withoutWrappers()
->findByColumn(
request()->getScalar('field')
);
}
Expand Down

0 comments on commit c2fe781

Please sign in to comment.