Benjamin
Benjamin
FFilament
Created by Benjamin on 6/5/2024 in #❓┊help
DatePicker/DateTimePicker alternative with manual typing support
Does anyone here already made a custom DatePicker/DateTimePicker or found an alternative version that allow manual typing ? I really need it and I know some people already asked for it (https://github.com/filamentphp/filament/discussions/6209 and https://github.com/filamentphp/filament/discussions/6817) so maybe I don't have to do it from scratch. Edit : It' s possible to use ->type('datetime-local') , but then I lost all DatePicker great utilities such as firstDayOfWeek(), disabledDates(), minDate() and maxDate(). Yes, minDate() and maxDate() can be replaced by something like ->extraInputAttributes(['max' => now()->isoFormat('YYYY-MM-DDTHH:mm')]), but the problem is that when using TextInput with a specific type, the field is not updated when using refreshFormData and a complete page reload (F5) is necessary. Thanks 🙏
14 replies
FFilament
Created by Benjamin on 5/1/2024 in #❓┊help
Refresh my form after custom "Cancel" action
Hi guys. I created an action that allow to cancel a mission (switch status + fill cancellation related fields). Those fields are visible on my MissionResource.php only if the status is CANCELLED.
Forms\Components\Section::make(__('Cancellation'))
->schema([
Forms\Components\DateTimePicker::make('cancelled_at')
->label(__('Cancelled at'))
->displayFormat('d.m.Y H:i')
->native(false),
Forms\Components\Select::make('cancellation_type')
->label(__('Cancellation type'))
->options(CancellationTypeEnum::class)
->required(),
Forms\Components\Textarea::make('cancellation_reason')
->label(__('Cancellation reason'))
->rows(3),
])
->visible(fn (?Mission $record): bool => $record && $record->mission_status === MissionStatusEnum::CANCELLED),
Forms\Components\Section::make(__('Cancellation'))
->schema([
Forms\Components\DateTimePicker::make('cancelled_at')
->label(__('Cancelled at'))
->displayFormat('d.m.Y H:i')
->native(false),
Forms\Components\Select::make('cancellation_type')
->label(__('Cancellation type'))
->options(CancellationTypeEnum::class)
->required(),
Forms\Components\Textarea::make('cancellation_reason')
->label(__('Cancellation reason'))
->rows(3),
])
->visible(fn (?Mission $record): bool => $record && $record->mission_status === MissionStatusEnum::CANCELLED),
The problem is, when the action is performed, the fields appears but they are not fill with the data I just typed, but those that where loaded at the loading of the page. I tried to use protected $listeners = ['refreshEditMissions' => '$refresh']; on the EditMissions.php page and dispatch the event in the action, I tried to use the refreshFormData method, but nothing is working. Please help 🙏 Here is my action code : https://pastebin.com/LNDJSQt6
4 replies
FFilament
Created by Benjamin on 3/6/2024 in #❓┊help
JS error : "Livewire assets are out of date"
Hi guys, I made a few changes on my Filament app and now login isn't working anymore and I think it's related to Livewire because I have this error in the console
Livewire: The published Livewire assets are out of date
See: https://livewire.laravel.com/docs/installation#publishing-livewires-frontend-assets
Livewire: The published Livewire assets are out of date
See: https://livewire.laravel.com/docs/installation#publishing-livewires-frontend-assets
and even the password input doesn't work anymore. Do you have any advice to help me ? I'm struggling since 2 hours on it... I also tried
php artisan livewire:publish --assets
php artisan livewire:publish --assets
, then livewire is correctly loaded but the login is just redirecting me to the login page.
6 replies
FFilament
Created by Benjamin on 2/20/2024 in #❓┊help
Trying to make a custom field (for custom complex component)
No description
5 replies
FFilament
Created by Benjamin on 2/15/2024 in #❓┊help
Is there a way to trigger a RelationManager "create" action from a Widget action ?
No description
5 replies
FFilament
Created by Benjamin on 10/26/2023 in #❓┊help
Unique rule with MorphToSelect fields
Hi ! I'm trying to create a form for a "relations" polymorphic table I have in my database to manage relations between three entities (Users, Companies and Institutions). Here is the table code :
Schema::create(self::TABLE_NAME, function (Blueprint $table): void {
$table->id();
$table->bigInteger('relationable_id')->unsigned();
$table->string('relationable_type');
$table->bigInteger('target_id')->unsigned();
$table->string('target_type');
$table->string('relation_type', 45);
$table->timestamps();
$table->index('relation_type');
$table->unique(['relationable_id', 'relationable_type', 'target_type', 'relation_type'], self::TABLE_NAME . '_unique');
});
Schema::create(self::TABLE_NAME, function (Blueprint $table): void {
$table->id();
$table->bigInteger('relationable_id')->unsigned();
$table->string('relationable_type');
$table->bigInteger('target_id')->unsigned();
$table->string('target_type');
$table->string('relation_type', 45);
$table->timestamps();
$table->index('relation_type');
$table->unique(['relationable_id', 'relationable_type', 'target_type', 'relation_type'], self::TABLE_NAME . '_unique');
});
I already used ->unique() method on classic Select fields like that :
Forms\Components\Select::make('user_id')
->relationship('user', 'v_fullname')
->unique(modifyRuleUsing: function (Unique $rule) {
return $rule
->where('model_type', Company::class)
->where('model_id', $this->getOwnerRecord());
})
Forms\Components\Select::make('user_id')
->relationship('user', 'v_fullname')
->unique(modifyRuleUsing: function (Unique $rule) {
return $rule
->where('model_type', Company::class)
->where('model_id', $this->getOwnerRecord());
})
But is there any possibility define a unique() rule on MorphToSelect fields ?
Forms\Components\MorphToSelect::make('relationable')
->label('Relationable')
->types([
Forms\Components\MorphToSelect\Type::make(Company::class)
->titleAttribute('name'),
Forms\Components\MorphToSelect\Type::make(Institution::class)
->titleAttribute('name'),
]),
Forms\Components\MorphToSelect::make('relationable')
->label('Relationable')
->types([
Forms\Components\MorphToSelect\Type::make(Company::class)
->titleAttribute('name'),
Forms\Components\MorphToSelect\Type::make(Institution::class)
->titleAttribute('name'),
]),
Thanks in advance !
2 replies
FFilament
Created by Benjamin on 10/11/2023 in #❓┊help
Can't edit a resource if viewAny() is false (Model Policy)
No description
5 replies
FFilament
Created by Benjamin on 9/20/2023 in #❓┊help
From v2 to v3 : translations not working anymore for all my selects
No description
3 replies
FFilament
Created by Benjamin on 9/4/2023 in #❓┊help
Help to create a custom fields (comments)
Hi ! Is there someone here who could help me to create a custom fields list and add comments ? I followed the docs but can't make it work 😦
15 replies
FFilament
Created by Benjamin on 8/21/2023 in #❓┊help
Trying to debug : Company::setTranslation(): Argument #2 ($locale) must be of type string, null...
4 replies
FFilament
Created by Benjamin on 7/25/2023 in #❓┊help
Translatable plugin : make relationship field works
13 replies
FFilament
Created by Benjamin on 7/25/2023 in #❓┊help
Select field : problem with getOptionLabelFromRecordUsing()
5 replies
FFilament
Created by Benjamin on 7/12/2023 in #❓┊help
Field with data from relationship (BelongsTo)
3 replies