Setting some fields content in extraItemActions modal

Hello everyone, I have a Repeater component with extraItemAction, and I want to set some additional fields inside action modal. Please look at this code to understand what I need to achieve:
Repeater::make('items')
->relationship('items')
->extraItemActions([
Action::make('image_settings')
->icon(Heroicon::Settings)
->modal(true)
->schema([
TextInput::make('title')
->label('Title'),

TextInput::make('alt_text')
->label('Alt Text'),
])
->action(function (array $data, Set $set) {
// I want to set the title and alt_text fields in the parent repeater item
$set('title', $data['title']);
$set('alt_text', $data['alt_text']);
}),

])
->schema([
FileUpload::make('path')
->label('File')
->multiple(false)
->storeFileNamesIn('filename')
->required(),
// Here I want to show the title and alt_text fields, but they should be hidden and only editable via the modal
Hidden::make('title')->live(),
Hidden::make('alt_text')->live(),
]);
Repeater::make('items')
->relationship('items')
->extraItemActions([
Action::make('image_settings')
->icon(Heroicon::Settings)
->modal(true)
->schema([
TextInput::make('title')
->label('Title'),

TextInput::make('alt_text')
->label('Alt Text'),
])
->action(function (array $data, Set $set) {
// I want to set the title and alt_text fields in the parent repeater item
$set('title', $data['title']);
$set('alt_text', $data['alt_text']);
}),

])
->schema([
FileUpload::make('path')
->label('File')
->multiple(false)
->storeFileNamesIn('filename')
->required(),
// Here I want to show the title and alt_text fields, but they should be hidden and only editable via the modal
Hidden::make('title')->live(),
Hidden::make('alt_text')->live(),
]);
unfortunately field content is not set after modal saving. What is the best way to achieve similar behaviour?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?