JonathanH-UK
JonathanH-UK
FFilament
Created by JonathanH-UK on 10/12/2023 in #❓┊help
How to prevent releationship creation on Fieldset when field _inside_ the Fieldset is empty
I've answered my own question on this 😆 It's really simple - I ignore $record and look at whether $state is null and if not whether the field I care about is set.
2 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
Ah right! I'm only using attach
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
N.B. the scaffold for Relation Managers generates a definition for public static function form(Form $form): Form but it doesn't seem to be used - Is this right?
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
I'm really puzzled now as to why I couldn't make it work before. It's so simple. Next challenge is to successfully add a boolean checkbox to the attach form which isn't backed by a Model and will be intercepted in the save hook
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
Thanks Dan - Yep. I don't know what I did differently in the past but I'm certain I tried this without it working before, but your example just worked perfectly 😄
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
Thanks Dan - I'll try that now. I'm fairly sure I tried something at least similar to this before 😬
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
For comparison, this is really simple and just works on the Table:
Tables\Columns\TextColumn::make('name')->formatStateUsing(function (Model $record) {
return $record->name . " (" . $record->organisation->name . ")";
}),
Tables\Columns\TextColumn::make('name')->formatStateUsing(function (Model $record) {
return $record->name . " (" . $record->organisation->name . ")";
}),
I just want to rewrite the label like this when I'm selecting the relation
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
My working copy is a big mess of commented sections at the moment. I've just tried resurrecting an attempt to use
$action->getRecordSelect()->getOptionLabelFromRecordUsing(function (Model $record) {
return $record->name . " (" . $record->organisation->name . ")";
}),
$action->getRecordSelect()->getOptionLabelFromRecordUsing(function (Model $record) {
return $record->name . " (" . $record->organisation->name . ")";
}),
And this is throwing an SQL exception and doesn't even trigger a dd() or Log statement inside my function... I remember that I was trying to debug it in the vendor code so I've hacked in a few Log statements etc which I'll have to review. The main problem is that this is something that must be one of the simplest and most common things that people (certainly me) would want to do with a relation manager and yet I've wasted many hours on it and there doesn't seem to be a documented example of this simplest case 😦
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
Method Filament\Tables\Actions\AttachAction::modifyRecordSelectUsing does not exist 😦 I'm just looking through my local branches as I think I have a better example than the one I gave above
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
Thanks Leandro - I'm not using a pivot attribute in this case and I've tried adapting that example before with no success 😦
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
I can try and generate another error / example.... I actually just logged this to try out Dan's new process as I've been meaning to come back to it for weeks
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
I've tried that one too ... There are several temptingly named methods but they either do nothing or cause a crash... IIRC I was looking at the source around that one. It's supposed to set up a callback which will be used to format the select but doesn't actually fire when set. I think this is specific to Relation Manager forms and am coming to the conclusion that this is a bug.
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
i.e. Even just trying to make a really simple custom select which only does the same as the default one results in 500 errors
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
My more recent attempt was this, but I've changed it and hacked it about many times and abandoned it a few times after spending >1hour getting nowhere..
Tables\Actions\AttachAction::make()->form([
Forms\Components\Select::make('trainees')->searchable()->relationship('trainees','Trainees'),
Forms\Components\Checkbox::make('is_chargeable')
->label('Charge for this booking?')
->default(true),
])
Tables\Actions\AttachAction::make()->form([
Forms\Components\Select::make('trainees')->searchable()->relationship('trainees','Trainees'),
Forms\Components\Checkbox::make('is_chargeable')
->label('Charge for this booking?')
->default(true),
])
29 replies
FFilament
Created by JonathanH-UK on 3/2/2023 in #❓┊help
How can I customise the select list on a Relationship Manager's modal form?
Any attempt to make a custom form on the AttachAction just blows up 😦
29 replies