Mike.
Hide Create an action in the form of a filament
I have a code like this
'use HasAvailableLeaves;
protected function getFormActions(): array
{
return [
CreateAction::make('create')
->label(__('Request'))
->submit('create')
->hidden(HasAvailableLeaves::hideIfNoAvailableLeaves())
];
}'
I want this code to disappear according to the trait that I have created, but in a code condition like this I get an error
An attempt was made to evaluate a closure for [Filament\Actions\CreateAction], but [$get] was unresolvable.
Code in trait
'public static function hideIfNoAvailableLeaves(): Closure
{
return function ($get) {
$userId = $get('user_id');
if (!$userId) {
return false;
}
$availableLeaves = SheetLeave::where('user_id', $userId)->first()?->available_leaves ?? 0;
return $availableLeaves === 0;
};
}'
30 replies
Spatie laravel-translatable
I am making an infolist resource then I want to display data from a relationship, the data appears successfully but the translation is not successful, even though in the filament view I have used translatable in the lits table it can be translated but in the infolist it can't, can anyone help, currently my code is only like this
TextEntry::make('location.name')
->label('Location'),
TextEntry::make('location.address')
->label('Address'),
TextEntry::make('location.city')
->label('City'),
2 replies
make all images clickable and display in full
currently my code is like this
SpatieMediaLibraryImageEntry::make('product-image')
->collection('product-images')
->label(''),
then I want this image to be clickable and it will appear in full in the infolist
8 replies
Creatinga a new option in select
i using this code in select
->createOptionForm([
TextInput::make('label')
->label('New category')
->required(),
RichEditor::make('description')
]),
and when this code is clicked it adds a + button next to the select column and opens a modal, and I also use searchable so I want when a record is searched and the record doesn't exist it displays the option to create a new record but without displaying the modal, so I can type the data directly in the select
4 replies
How to disabled select in form
i have this code
Select::make('status')
->label('Status')
->required()
->options(collect(InvitationStatus::getValues())
->filter()
->mapWithKeys(fn ($value) => [$value => ucfirst($value)])
->toArray()
)
->default(InvitationStatus::PENDING->value)
->afterStateHydrated(fn ($set, $state) => $state ?: $set(InvitationStatus::PENDING->value)),
but i want to select this disabled,when i try to add '->disabled()' it gets error "General error: 1364 Field 'status' doesn't have a default value" can someone help me
4 replies