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]);
}),
]),
3 Replies
krekas
krekas2mo ago
If you are trying to access repeater field outside of repeater you need to use nested syntax ../
jemont_04812
jemont_04812OP2mo ago
Hi, thanks for your reply. I don't want to access a field outside the repeater. both fields are inside the same repeater item. I want to access the extraInputAttributes array of the field with the attached action to it. I use this in 2 different places once in the resource form for a page or blog post and once for a navigation builder inside a Repeater field. It works in the resource form, but in the repeater it doesn't
Want results from more Discord servers?
Add your server