Skip to content

Can't use SpatieTagsInput in a bulk action #465

Answered by robschmitt
robschmitt asked this question in Q&A
Discussion options

You must be logged in to vote

I've discovered a workaround that might be painfully obvious to FilamentPHP experts. It seems the key is to enable dehydration on the SpatieTagsInput field when defining the form on the bulk action, for example:

return $table
  ...
  ->bulkActions([
    Tables\Actions\DeleteBulkAction::make(),
    Tables\Actions\BulkAction::make('tag')
      ->form([
        Forms\Components\SpatieTagsInput::make('tags')->dehydrated(true),
      ])
      ->action(function (Collection $records, array $data): void {
        // $data has a key of 'tags' with an array of tags selected
      })
      ->icon('heroicon-o-tag'),
    ]);

Might be a good idea to get this into the documentation.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by robschmitt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #464 on June 28, 2023 07:09.