F
Filamentβ€’2mo ago
omar abdou

How to set tags to a TagsInput using $set

Hello i would like some help to set tags using $set i have tried :
$set('tags', 'a,tag');
$set('tags', ['a','tag']);
$set('tags', ['tag'=>'tag']);
$set('tags', 'a,tag');
$set('tags', ['a','tag']);
$set('tags', ['tag'=>'tag']);
as show in the image , it shows as if the input is not empty but not displaying anything, thank you for the help
No description
9 Replies
LeandroFerreira
LeandroFerreiraβ€’2mo ago
in the create form, you can use ->default(['a', 'b'])
omar abdou
omar abdouOPβ€’2mo ago
as you can see in tthe image , i added an action on the right , i am setting the tags from that action
LeandroFerreira
LeandroFerreiraβ€’2mo ago
try this
TagsInput::make('tags')
->suffixAction(Action::make('add')
->icon('heroicon-o-user-plus')
->form([
TextInput::make('name')
])
->action(function (array $data, Page $livewire) {
$livewire->data['tags'][] = $data['name'];
}))
TagsInput::make('tags')
->suffixAction(Action::make('add')
->icon('heroicon-o-user-plus')
->form([
TextInput::make('name')
])
->action(function (array $data, Page $livewire) {
$livewire->data['tags'][] = $data['name'];
}))
omar abdou
omar abdouOPβ€’2mo ago
Failed
Property [$data] not found on component: [app.filament.admin.resources.meeting-resource.pages.manage-meetings]
Property [$data] not found on component: [app.filament.admin.resources.meeting-resource.pages.manage-meetings]
No description
LeandroFerreira
LeandroFerreiraβ€’2mo ago
$livewire->mountedActionData ?
omar abdou
omar abdouOPβ€’2mo ago
$livewire->mountedActionsData['tags'][] = $data['employee_id']; does not throw an error but tags are not set , the input has no value
LeandroFerreira
LeandroFerreiraβ€’2mo ago
Share the whole code on gist please
omar abdou
omar abdouOPβ€’2mo ago
Gist
example.php
GitHub Gist: instantly share code, notes, and snippets.
LeandroFerreira
LeandroFerreiraβ€’2mo ago
Hey, sorry for the delay
->action(function (array $data, Page $livewire) {
$tags = $livewire->mountedActionsData[0]['tags'];
$tags = array_merge($tags, $data['employee_id']);
})
->action(function (array $data, Page $livewire) {
$tags = $livewire->mountedActionsData[0]['tags'];
$tags = array_merge($tags, $data['employee_id']);
})
@omar abdou, did it work? πŸ‘†

Did you find this page helpful?