Saade
Saade
FFilament
Created by Saade on 11/21/2023 in #❓┊help
Bind $record in a custom action
Giving the following component:
// Component
class MyPage extends Component implements HasForms, HasActions
{
use InteractsWithForms;
use InteractsWithActions;

public function editAction(): Action
{
return Action::make('edit')
->mountUsing(function (Action $action, array $arguments): void {
// Resolve
$record = Author::find($arguments['id']);

// I'm guessing this, this will not work.
$action->record($record);
})
->form([
TextInput::make('title'),
Repeater::make('books')->relationship('books') // Repeater must know $record in order to work
])
->action(function (array $data, Model $record) {
$record->update($data);
})
}
}
// Component
class MyPage extends Component implements HasForms, HasActions
{
use InteractsWithForms;
use InteractsWithActions;

public function editAction(): Action
{
return Action::make('edit')
->mountUsing(function (Action $action, array $arguments): void {
// Resolve
$record = Author::find($arguments['id']);

// I'm guessing this, this will not work.
$action->record($record);
})
->form([
TextInput::make('title'),
Repeater::make('books')->relationship('books') // Repeater must know $record in order to work
])
->action(function (array $data, Model $record) {
$record->update($data);
})
}
}
<div>

Authors:

<span>Guilherme Saade {{ ($this->editAction)(['id' => 1]) }}</span>
<span>Dan Harrin {{ ($this->editAction)(['id' => 2]) }}</span>

<x-filament-actions:modals/>
</div>
<div>

Authors:

<span>Guilherme Saade {{ ($this->editAction)(['id' => 1]) }}</span>
<span>Dan Harrin {{ ($this->editAction)(['id' => 2]) }}</span>

<x-filament-actions:modals/>
</div>
How can i make the repeater know that the record is the $record resolved on mount? Made a little repro repo with everything set up, no need for migrations and seeders https://github.com/saade/filament-lab/tree/action-record
70 replies
FFilament
Created by Saade on 8/1/2023 in #❓┊help
`null` query params
Livewire is adding null query parameters to the URL and not removing them
27 replies
FFilament
Created by Saade on 7/31/2023 in #❓┊help
Table inside simple resource's modal
Is there an option to view a table inside the resource edit modal? I need to put a table inside the edit modal (below the form fields) to act like a view-only relation manager
6 replies
FFilament
Created by Saade on 7/29/2023 in #❓┊help
Change state before dehydration
For context, i have a DateTimePicker component for selecting the event's start date. If the user marks the all_day checkbox, i need the component to set the hour to 00:00:00 but keeping the date. eg: 28/07/2023 -> 28/07/2023 00:00:00. The thing is: I know i can do this with ->dehydrateStateUsing() but this will override the default dehydration process, which i need because it handles the timezone stuff behind the scenes.. How can i mutate the state before the dehydration process?
28 replies
FFilament
Created by Saade on 7/28/2023 in #❓┊help
Prevent table checkbox from growing
31 replies
FFilament
Created by Saade on 3/10/2023 in #❓┊help
DatePicker creating records wrongly but editing correctly
I have an app configured with UTC timezone, and form with the following date picker (DATE ONLY, no time):
Forms\Components\DatePicker::make('start_date')
->label('Data de início')
->timezone('America/Sao_Paulo')
->required(),
Forms\Components\DatePicker::make('start_date')
->label('Data de início')
->timezone('America/Sao_Paulo')
->required(),
If i select 2023-03-09 in the form, it CREATES in the database as 2023-03-09 (wrong, it should save as D-1) If i view the record, it will show as 2023-03-08 (wrong, because of timezone) Then i edit this date back to 2023-03-09 and it UPDATES to 2023-03-10 (correct, D-1) If i view the record, it will show as 2023-03-09 (which is now correct) WTF is going on? Am i dumb and don't know how timezone works?
20 replies