max_dev
max_dev
FFilament
Created by max_dev on 1/15/2024 in #❓┊help
Before createNewEntry ask for a related entry first
I want to create a function which opens a modal before the CreateAction of a Model in order to select a Customer first, before i can create the Booking. So i have an db column called 'customer_id' and it should be filled by the User BEFORE starting the creation process, because otherwise i get an error due to the depenant information can't be called, because the 'customer_id' field is empty The relevant code for the error:
Placeholder::make('company')
->label('Anschrift')
->content(fn (Booking $record): HtmlString => new HtmlString($record->customer->company . '<br /> ' . $record->customer->street . ' ' . $record->customer->housenumber . ' <br /> ' . $record->customer->plz . ' ' . $record->customer->city . ' <br /> ' . $record->customer->country) ?? 0),
Placeholder::make('company')
->label('Anschrift')
->content(fn (Booking $record): HtmlString => new HtmlString($record->customer->company . '<br /> ' . $record->customer->street . ' ' . $record->customer->housenumber . ' <br /> ' . $record->customer->plz . ' ' . $record->customer->city . ' <br /> ' . $record->customer->country) ?? 0),
App\Filament\Resources\BookingResource::App\Filament\Resources{closure}(): Argument #1 ($record) must be of type App\Models\Booking, null given, called in /var/www/html/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
1 replies
FFilament
Created by max_dev on 11/29/2023 in #❓┊help
recordClasses() is only correctly applied to the first entry of a Table
https://filamentphp.com/docs/3.x/tables/advanced#custom-row-classes Calling this fn in the table view leads to only style the first row correctly - every other row falls back to default even the returns are true
->recordClasses(fn (Booking $record) => match ($record->state) {
State::InApproval => 'border-l-4 border-red-600',
State::Approved => 'border-l-4 border-blue-600',
State::Invoiced => 'border-l-4 border-blue-600',
State::Paid => 'border-l-4 border-green-600',
default => null,
})
->recordClasses(fn (Booking $record) => match ($record->state) {
State::InApproval => 'border-l-4 border-red-600',
State::Approved => 'border-l-4 border-blue-600',
State::Invoiced => 'border-l-4 border-blue-600',
State::Paid => 'border-l-4 border-green-600',
default => null,
})
9 replies