soand
soand
FFilament
Created by soand on 4/22/2025 in #❓┊help
$livewire->dispatch('refresh') not updating data
Hi all! I have a form where some of the form is in it's own section, where I've used the footerActions on the form to allow the user to save some of the form data. But when saving the data in that action, the form doesn't rerender or reload or show any updates. I could find some posts in here mentioning using the $livewire->dispatch('refresh') which sort of works, but it doesn't update the latest changes, only the second latest if that makes sense? an example:
Section::make()->schema([
App\Models\Test::all()->map(fn ($test) => return TextInput::make('test_'.$test->id)->disabled(fn() => $test->closed_at));
])->footerActions([
Action::make('save')
->label('Save')
->action(function($get, $livewire) {
$tests = App\Models\Test::all();
foreach($tests as $test) {
$value = $get('test_' . $test->id);
$test->update(['value' => $value, 'closed_at' => now()]);
$livewire->dispatch('refresh')
}
})
]);
Section::make()->schema([
App\Models\Test::all()->map(fn ($test) => return TextInput::make('test_'.$test->id)->disabled(fn() => $test->closed_at));
])->footerActions([
Action::make('save')
->label('Save')
->action(function($get, $livewire) {
$tests = App\Models\Test::all();
foreach($tests as $test) {
$value = $get('test_' . $test->id);
$test->update(['value' => $value, 'closed_at' => now()]);
$livewire->dispatch('refresh')
}
})
]);
When i input the value in the first field and press save, it saves the information but it doesn't update the "disabled" to true, but when i just continue also inputting data in the next field and pressing save, the first field os now disabled but not the one I've just updated
2 replies
FFilament
Created by soand on 1/27/2025 in #❓┊help
Search should ignore filters
When setting multiple columns as searchable there is a search bar on the table. Is there any way to to set the search to always ignore any filters that might be set?
5 replies
FFilament
Created by soand on 11/25/2024 in #❓┊help
require conditionally
I'm creating an action on a table opening a modal where i want some extra data before i "close" the record. so i have 2 buttons in the modal, one to just save, so it can still be editted, and one to save and close the record. after closing the extra data can't be edited anymore. So i want the "answer" field to be required only when i have the "close" argument in the action. Is there any way to do this?
Action::make('edit')
->button()
->fillForm(fn ($record) => $record->toArray())
->form([
TextInput::make('answer'),
])
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('save_and_close', arguments: ['close' => true])->label(__('Save and close')),
])
->action(function ($record, $data, $arguments) {
$record->update($data);
if ($arguments['close] ?? false) {
$record->closed_at = now();
$record->save();
}
})
Action::make('edit')
->button()
->fillForm(fn ($record) => $record->toArray())
->form([
TextInput::make('answer'),
])
->extraModalFooterActions(fn (Action $action): array => [
$action->makeModalSubmitAction('save_and_close', arguments: ['close' => true])->label(__('Save and close')),
])
->action(function ($record, $data, $arguments) {
$record->update($data);
if ($arguments['close] ?? false) {
$record->closed_at = now();
$record->save();
}
})
2 replies
FFilament
Created by soand on 4/20/2024 in #❓┊help
Simple modal resource extra actions
I have create a "simple" resource which opens in a modal following this: https://filamentphp.com/docs/3.x/panels/resources/getting-started#simple-modal-resources Is there any way to add an extra action in the footer of the form in the modal? On a normal resource i can use the getFormActions on the EditRecord. But on a simple resource i only seem to have a ManageRecords
5 replies
FFilament
Created by soand on 10/22/2023 in #❓┊help
Get relationship Select record data from $get
when using a form field for a select on a belongsTo from the model is there anyway to get the data from the field selected when using $get?
Select::make('connection_id')
->relationship('connection', 'name')
->live()
->required(),
Select::make('connection_id')
->relationship('connection', 'name')
->live()
->required(),
Section::make('Action details')
->description()
->schema(function (Get $get): array {
dd($get('connection_id')); // returns only the id of the select relation
return [
];
})
Section::make('Action details')
->description()
->schema(function (Get $get): array {
dd($get('connection_id')); // returns only the id of the select relation
return [
];
})
2 replies
FFilament
Created by soand on 9/25/2023 in #❓┊help
Form section that saves to a json column
Hi! I'm trying to make a form with a section that has different details based on a type, kind of a form within a form. Is there any way to wrap fields within it to make it available as a json object I can save to a column? My example is different integrations, so an integration record has a name and logo, and then a type like "facebook" or "google ads". When choosing a type I set a set of fields for that platform as the credentials is different. I'm not going to query on the credentials at any point so it seems better to just save it in a json column rather than having unique table for each type and using relations. Is there any way in filament to wrap a Section or Grid or something so all fields within the section to be saved as json instead of just adding the fields to the $data array?
7 replies
FFilament
Created by soand on 7/26/2023 in #❓┊help
Conditionally opt out of tenancy
I know this is kind of a weird one, but I'm looking to have all my users scoped to tenants but one or two admin users to not be scoped to be able to administrate all the users of the app. Anyone know how to achieve this?
7 replies