CGM
Adding 'confirmation modal' to a checkbox?
I feel like I'm missing something simple in the docs in regards to action modals.
Is there a way to add a 'are you sure you want to toggle this checkbox' style of modal to a checkbox field? Something that would pop up with a confirmation before ->updateStateUsing() is called?
I'm using a table builder checkbox colum
11 replies
Prefill Resource Create Fields from beforeFill()?
I'm looking to prefill some resource fields (when Creating a resource) using values from a cookie. Is the beforeFill() Life Cycle hook an appropriate place to do this? If so, how do I actually interact with the $form from inside this hook?
Is there another more appropriate place to do this?
9 replies
Where to put custom logic shared across multiple Resource classes
Just looking for some guidance on where might be the most appropriate place to put logic that I'm looking to share across multiple Resource classes. My auth logic for some of the action buttons (to hide/show them) is getting a little long and I don't like having the same code in 8 different places. Where might be the best place to put this custom logic? Is there a 'filament way' or am I better off creating a new trait?
4 replies
How do I test MorphToSelect fields in forms?
I'm trying to write a test to ensure my MorphToSelect field is ->required(), but it is not behaving as I would expect. Are you all aware of any examples of testing the MorphToSelect field in custom forms, or even in panel forms?
Here is the field for reference:
Here is the example field for reference:
3 replies
Changing the MorphToSelect Placeholder
Is there a way to change the MorphToSelect placeholder?
I get this error when using
->placeholder()
Method Filament\Forms\Components\MorphToSelect::placeholder does not exist.
I'm looking to change the text that reads "Select an option" for the initial 'type' selection.2 replies
How can I use @error blade directives in my custom form field blade files?
I know it's me missing something obvious, but I'm struggling to properly use @error() @enderror in my custom fields blade file.
What goes inside of @error(<here>)?
I attempted source diving and found
$errors->has($statePath)
but this gives me an error: array_key_exists(): Argument #1 ($key) must be a valid array offset type
when I try to use it in my own blade template.
This is a field created using artisan make:form-field
, so nothing too special I don't think.3 replies
How to test pages that extend extend ManageRelatedRecords (Create via Modal)
How would you properly setup a simple test for a custom page that extends ManageRelatedRecords?
This is a standard page create using
make:filament-page
and selecting Relationship.
The form is in a Modal and I think that is where I'm getting stuck.
I would love to see an example of how to just see how to assert the successful submission of a create form (no errors) via the modal. I think I could plow through the rest from there. 🙂8 replies
How do I refresh my table when I interact with a ToggleColumn?
Is there an easy way to make ToggleColumn::make() reactive, or to get it to refresh the entire table after being toggled? I have other columns that depend on the state of these toggles, but I can't get the updates to the browser without refreshing the page manually.
I've tried things like $this->dispatch('$refresh') from different column callbacks, etc but without any luck. Adding <button wire:click="$refresh">Refresh component</button> to a button works, but I want the table to refresh when the toggle is toggled.
7 replies
Testing Form Wizards
I'm attempting to test a form wizard's
->beforeValidation()
call (as part of Wizard\Step) in a test, but I don't know how to 'forward' the wizard to the correct step. Is there a way to move a test forward to 'step 2' in a unit test so I can test functions like ->afterValidation()
and ->beforeValidation()
?
I can't seem to get code in those methods to fire at all during tests.2 replies
How do I prevent JSON fields from being blown away when using dot notation on TextInputs?
What I'm trying to do:
I'm trying to store data into a JSON field using a TextInput while using dot notation.
Forms\Components\TextInput::make('additional.industry')
additional
is my JSON field, industry
is the key in that field I'm editing.
My Issue
My JSON field has data other than just the 'industry' key, and it is being set elsewhere.
When I save submit the Filament form, additional.industry
saves what I'm expecting, however every other JSON key is blown away.
Example:
JSON field before saving:
{"other": "other data here", "industry": "service"}
JSON field after saving
{"industry": "service"}
Question
How do I preserve the rest of the JSON structure when saving while using dot notation for a TextInput field?9 replies