F
Filament3mo ago
lmtc

Saving data on modal submission builder

I have this code but it's not saving the full form when I submit:
->action(function (
array $data,
array $arguments,
Pages $record,
Set $set,
) {
$set('content_blocks.'.$arguments['item'].'.data.styling_options',
$data);
$record->save();
}),
->action(function (
array $data,
array $arguments,
Pages $record,
Set $set,
) {
$set('content_blocks.'.$arguments['item'].'.data.styling_options',
$data);
$record->save();
}),
7 Replies
toeknee
toeknee2mo ago
What is the full form.
lmtc
lmtc2mo ago
@toeknee
BuilderComponent::make('blocks')
->label('')
->addActionLabel('Add Block')
->extraItemActions([
Action::make('add_component_styling')
->icon('heroicon-s-paint-brush')
->label('Styling Options')
->fillForm(function (
array $data,
array $arguments,
BuilderComponent $component
) {
$item_data = $component->getItemState($arguments['item']);
return [

];
})
->form([
])
->action(function (
array $data,
array $arguments,
Pages $record,
Set $set,
) {
$set('blocks.'.$arguments['item'].'.data.block_styling_options',
$data);
}),
])
->reorderableWithButtons()
->cloneable()
->collapsible()
->blocks([
BuilderComponent\Block::make('image')
->schema([
Hidden::make('block_styling_options'),
Grid::make(2)
->schema([
BuilderComponent::make('blocks')
->label('')
->addActionLabel('Add Block')
->extraItemActions([
Action::make('add_component_styling')
->icon('heroicon-s-paint-brush')
->label('Styling Options')
->fillForm(function (
array $data,
array $arguments,
BuilderComponent $component
) {
$item_data = $component->getItemState($arguments['item']);
return [

];
})
->form([
])
->action(function (
array $data,
array $arguments,
Pages $record,
Set $set,
) {
$set('blocks.'.$arguments['item'].'.data.block_styling_options',
$data);
}),
])
->reorderableWithButtons()
->cloneable()
->collapsible()
->blocks([
BuilderComponent\Block::make('image')
->schema([
Hidden::make('block_styling_options'),
Grid::make(2)
->schema([
I excluded the actual form - it's working to set the data outside, but ideally I don't want to have to hit save for the whole page since it's a bit annoying
toeknee
toeknee2mo ago
What do you mean?
lmtc
lmtc2mo ago
So the set is working from the action to the field in the actual form, but I want it to save the whole form on submit
toeknee
toeknee2mo ago
I still need more context, when you click save / submit it will save the whole form? What isn’t happening
lmtc
lmtc2mo ago
when I click submit, it doesn't seem to save the whole form but it does set the field, I want it to save the whole form
toeknee
toeknee2mo ago
So it does save the whole form.... if yours isn't then we need to see the whole code. You either haven't allowed fillable on the model for the fields to actually save Or you are saving relationships and expecting to see that data in the action closure
Want results from more Discord servers?
Add your server