Nuekrato
FileUpload: How to handle file removal?
I need to show a checkbox if the upload contains executable files. This works for the initial file upload. But if the user removes files he already uploads (and removes the executables) the checkbox is still shown. I use the
afterStateUpdate
-method to hide/show the checkbox. But sadly afterStateUpdated
is not called if a file is removed in the FileUpload-component. Is this a bug? Is there another method to achieve the desired behaviour?1 replies
How to use a custom policy for a custom resource page or disable authorization entirely?
Is it possible to use a custom policy for a custom resource page? Lets say I have a page to download files from an existing resource. I want to use a custom policy
download
for this resource. How can I manage access to the page? It seems like the model policies take precedence over the canAccess()
-method of the page. So the "normal" model policies deny access to the custom resource download page, because I can't define the download policy for this resource page.14 replies
canAccess() is called on every page/resource AFTER logout resulting in an exception?
I use a default panel for Filament but I have problems on using the default logout - either frm the user dropdown in the top navigation bar or using the account widget logout button. After clicking logout Filament redirects and calls the /logout route using a POST request. During that I get an error 500 and the following exception (see logs attached).
This is the method that produces the error from my FeatureSettingsPage:
So there is nothing special here. But the problem is very strange: Why should Filament call this method? After logging out I should be redirected to the login page and there is no need to call the
canAccess()
method on specific pages? I tried to return just true
in the canAccess()
-method but then Filament just calls the next canAccess
-method from another page and so on.
I removed the path for the panel provider because I want to host the default panel on the default path without any prefix:
From my App\Providers\Filament\AppPanelProvider:
4 replies
Relation Manager: How to customize edit action?
Given the following example of a
form
in a relation manager:
How can I hook into the updating process of the edit action of the form? A lot of the docs only mention resource pages and not the relation manager itself.
What I want to achieve:
- Set the pivot model's attribute to ['*']
if the checkbox is selected. I tried it using afterStateUpdated
but that doesn't work.
I think I need to hook into the form's lifecycle but it seems like a Relation Manager does not have anything like https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-saving nor https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-the-saving-process. Also this https://filamentphp.com/docs/3.x/actions/prebuilt-actions/edit#customizing-the-saving-process doesn't work, because the EditAction is only indirectly used in the form
method of the Relation Manager?2 replies
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