Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make refreshFormData public #12797

Merged
merged 1 commit into from
May 15, 2024
Merged

Make refreshFormData public #12797

merged 1 commit into from
May 15, 2024

Conversation

SebastianSchoeps
Copy link
Contributor

Description

I want to refresh the form data with refreshFormData in a hint action in a resource class.

public static function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TagsInput::make('assignment_terms')
                ->placeholder('')
                ->hintAction(
                    Forms\Components\Actions\Action::make('editAssignmentTerms')
                        ->form([
                            Forms\Components\TagsInput::make('assignment_terms')
                                ->default(fn($record) => $record->assignment_terms)
                        ])
                        ->action(function ($record, $data, $livewire) {
                            $record->update($data);
                            $livewire->refreshFormData(['assignment_terms']);
                        }),
                ),
        ]);
}

The line $livewire->refreshFormData(['assignment_terms']); won't work currently because the method is protected in both ViewPage and EditPage.
The workaround is to override the method in my view and edit page. With this PR accepted that would not be necessary.

Visual changes

None.

Functional changes

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

@danharrin danharrin added the enhancement New feature or request label May 15, 2024
@danharrin danharrin added this to the v3 milestone May 15, 2024
@danharrin danharrin merged commit b36f863 into filamentphp:3.x May 15, 2024
11 checks passed
@cirino
Copy link

cirino commented May 16, 2024

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants