Skip to content

Conversation

@People-Sea
Copy link
Contributor

@People-Sea People-Sea commented Jan 19, 2026

Description

fixes: #18687

fix: Before mounting an action, if a ValidationException is thrown, call unmountAction so that form validation errors render correctly.

It requires developers to verify by themselves in mountUsing.

Alternative solution: add a preMountFieldValidation method to validate form fields before mounting.

Repeater::make('sec')
    ->minItems(1)
    ->defaultItems(1)
    ->required()
    ->columnSpanFull()
    ->extraItemActions([
        Action::make('fields options')
            ->slideOver()
            ->mountUsing(function (Repeater $component, $arguments){
                $component->getChildSchema($arguments['item'])->validate();

                // or auto validate
                // $component->getItemState($arguments['item']);
            })
            ->modalHeading(function(Repeater $component, $arguments) {
                return $component->getItemState($arguments['item'])['title'];
            })
            ->schema([
                Textarea::make('desc')
                    ->nullable(),
            ])
    ])
    ->schema(function () {
        return [
            TextInput::make('title')
                ->required()
        ];
    });

Visual changes

before

Calling getItemState directly within modalHeading will result in a ValidationException.

before.mp4

after

Call the verification in the mountUsing.

after.mp4

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Repeater] validation of item fields not working when getting state from extraItemActions

1 participant