Nuekrato
CheckboxList: modifyOptionsQueryUsing does not exist
The docs say there should be this method to modify the options but this method does not exist:
https://filamentphp.com/docs/3.x/forms/fields/checkbox-list#customizing-the-relationship-query
I currently need to accomplish exactly that: Set the relationship based on a different table than the options.
Example code:
This code is inside a GroupRelationManager of a Template. A
Group
can belong to templatePermissions (which is the name of the relationship of the group) - but the options are coming from another table. Using the CheckboxList like this gives a wrong result. Also the modifyQueryUsing
-method is not called as long as options
is set. If I comment out ->options(...)
the modifyQueryUsing
is called.5 replies
Form: Adding user-defined pivot data to belongsToMany relationship
I have a form like this:
allowedTargets
is a many-to-many-relationship of my Model. Each target has a pivot column allowed_file_extensions
which accepts an array of file extensions as strings.
Using a TextInput
inside the pivotData()
-method is not doing anything. But it is also not documented and was just an example what I already tried. I want the user be able to add allowed_file_extensions as pivot data on the create page of my Model. So he is able to create the parent model directly with the relationship and the specific pivot data. Is that possible?
I also tried it using a RelationManager but it seems like RelationManagers don't show up on the resource create page.5 replies
Form: Nested JSON values are stored as string instead of integers
I have a form like:
And my model even casts the json values:
But if I save my form the model is created in the databse with string values in the JSON column (see the
file_expire_days
):
{"base_path": "test", "file_expire_days": "15", "auto_delete_files": true, "project_expire_days": 30, "notify_project_expire_days": [14, "7", "1"]}
If I leave the default value it is saved correctly as an integer. How can I tell filament that the values should be stored according to the model cast?4 replies
How to get $data from table form action?
I built a rather complex action in my table which looks like this:
This works perfectly fine and correctly sets the user's permissions in their project. The problem is that I am just not able to get the
$data
in the ->action
-method. After submitting the form the $data
seems to be empty:
[2024-05-08 08:31:58] production.DEBUG: Permissions data
So the ->action
-method is triggered correctly but is not getting any data back from the form?9 replies
Custom field: bind array data
I created a custom field and this custom field renders mutliple Filament Checkboxes:
As you can see I bind the input to the
state
. The problem is that this binds every Checkbox to the state and this results in every checkbox using the same state (so only one true/false value for all checkboxes). How can I bind each checkbox to an array in the state?55 replies