carloscapote
carloscapote
FFilament
Created by carloscapote on 10/22/2023 in #❓┊help
Weird things occur when setting and unsetting a DateTimePicker value
When trying to set (or unset) the value of a DateTimePicker, weird things happen. I prepared this example to show what I'm experiencing. Please, let me know if you experience the same, or if I'm missing something.
Select::make('status')
->required()
->live()
->options([
'draft' => trans('Draft'),
'published' => trans('Published'),
])
->afterStateUpdated(function ($state, Set $set) {
$published = ($state === 'published') ? now() : null;

$set('text_published_at', $published);
$set('non_native_date_published_at', $published);
$set('native_date_published_at', $published);
}),

TextInput::make('text_published_at'),

DateTimePicker::make('non_native_date_published_at')->native(false),

DateTimePicker::make('native_date_published_at')->native(true),
Select::make('status')
->required()
->live()
->options([
'draft' => trans('Draft'),
'published' => trans('Published'),
])
->afterStateUpdated(function ($state, Set $set) {
$published = ($state === 'published') ? now() : null;

$set('text_published_at', $published);
$set('non_native_date_published_at', $published);
$set('native_date_published_at', $published);
}),

TextInput::make('text_published_at'),

DateTimePicker::make('non_native_date_published_at')->native(false),

DateTimePicker::make('native_date_published_at')->native(true),
Add the fields above to a form and then change the value of the first select. - When the value is set to Draft, the fields below are expected to be emptied as it occurs with the text input. - When the value is set to Published, the fields below are expected to be updated with the current timestamp as it occurs with the text input. But the date time pickers don't seem to like being updated: - The non native field accepts a new date when it's initially empty but rather than being cleared when the select is set to Draft, it changes to a different date time value (which isn't even the current timestamp). - The native field is worse, as it doesn't even change no matter what I do with the select.
4 replies
FFilament
Created by carloscapote on 9/27/2023 in #❓┊help
How do you test FileUpload input fields?
I've been checking the docs but I didn't find any example about how to test FileUpload fields. How do you do it? Does anyone have links to code examples?
4 replies
FFilament
Created by carloscapote on 9/14/2023 in #❓┊help
Disable field if a relation manager has records
Let's say I've an order with lines and I want a select field that's in the header to be disabled if the order already has lines. I can just add a:
Select::make('field')
->disabled(fn (Order $order) => $order->lines()->count())
Select::make('field')
->disabled(fn (Order $order) => $order->lines()->count())
... and it will work but only when the page is entirely refreshed. It won't behave live as lines are added or removed. How can I achieve that dynamism? Maybe with events?
7 replies