jemont_04812
jemont_04812
FFilament
Created by jemont_04812 on 11/1/2024 in #❓┊help
Suffix Action in Repeater Field
hi, I have a TextInput field with suffix actions to toggle readonly. it works if directly in a resource form, however if inside a Repeater or Builder field it doesn't work and I don't get an error message. This is the field definition Can anybody tell me what I am missing?
TextInput::make('title')
->live(onBlur: true)
->afterStateUpdated(
function (string $operation, Component $component, Set $set, Get $get, string $state) {
$set('slug', Str::slug($state));
})
->columnSpan(2),
TextInput::make('slug')
->live(onBlur: true)
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state)))
->extraInputAttributes(['readonly' => true])
->suffixActions([
Action::make('lockSlug')
->visible(fn ($component) => in_array('readonly', $component->getExtraInputAttributes()))
->icon('heroicon-o-lock-closed')
->action(function (Component $component) {
$component->extraInputAttributes(['readonly' => false]);
}),
Action::make('unlockSlug')
->visible(fn ($component) => in_array('readonly', $component->getExtraInputAttributes()) == false)
->icon('heroicon-o-lock-open')
->action(function (Component $component) {
$component->extraInputAttributes(['readonly' => true]);
}),
]),
TextInput::make('title')
->live(onBlur: true)
->afterStateUpdated(
function (string $operation, Component $component, Set $set, Get $get, string $state) {
$set('slug', Str::slug($state));
})
->columnSpan(2),
TextInput::make('slug')
->live(onBlur: true)
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state)))
->extraInputAttributes(['readonly' => true])
->suffixActions([
Action::make('lockSlug')
->visible(fn ($component) => in_array('readonly', $component->getExtraInputAttributes()))
->icon('heroicon-o-lock-closed')
->action(function (Component $component) {
$component->extraInputAttributes(['readonly' => false]);
}),
Action::make('unlockSlug')
->visible(fn ($component) => in_array('readonly', $component->getExtraInputAttributes()) == false)
->icon('heroicon-o-lock-open')
->action(function (Component $component) {
$component->extraInputAttributes(['readonly' => true]);
}),
]),
5 replies