Bruno Silva
Using Spatie/Laravel-Data to validate Filament Forms
Is it possible to take advantage of Laravel Data to validate Filament forms?
Some projects require using Laravel Data for proper validation in different contexts (API, commands, jobs, etc), and it becomes redundant to duplicate validation rules in Filament forms for every resource. I'm looking for a way to integrate both effectively. Here's my current approach: While this basic implementation works for validation rules, it doesn't leverage other Laravel Data features like: - Custom validation messages - Type casting - Complex validations - Data Object reusability Has anyone found a more elegant solution to integrate these tools? Any advice or examples would be greatly appreciated!
Some projects require using Laravel Data for proper validation in different contexts (API, commands, jobs, etc), and it becomes redundant to duplicate validation rules in Filament forms for every resource. I'm looking for a way to integrate both effectively. Here's my current approach: While this basic implementation works for validation rules, it doesn't leverage other Laravel Data features like: - Custom validation messages - Type casting - Complex validations - Data Object reusability Has anyone found a more elegant solution to integrate these tools? Any advice or examples would be greatly appreciated!
1 replies
Unable to hide childItems in custom NavigationItem
I'm making a custom navigation setup and I want to conditionally hide an item from the
childItems([...])
, but it does not seem to work...
this is a simple code to debug it faster, "nav-item-5" should be hidden
4 replies
conditionally set dark mode
is it possible to set dark mode based on certain config? I want to disable the theme mode switcher and set the dark mode based on a setting from laravel settings, but I can't figure out how to do it (as the darkMode method do not accept closure)
6 replies
Require Login/Register to Execute Action
I have a public page (Livewire component) with a Filament form:
I wish to submit this form and execute some code after the user logs in or registers...
The flow would be:
- Fill out the form
- Click the submit button
- Register or Login
- Use that user recently created or logged user to execute some code
Is that possible using the Filament login/register form?
9 replies
Checkboxlist selecting all options
I have a simple CheckboxList, but when I click in one option, it selects or deselects all of them. The only difference of that checkboxlist is that it is in a resource from another panel (my "client" panel, which is not the default "admin" one)
* other fields in the same form works as they should.
7 replies
livewire()->fillForm() not working
I have several tests using the same helper. All tests are working except for one, and I can't figure out why. I'm going to leave the simplest example possible just to show the problem:
VehicleTest:
VehicleResource:
CreateVehicle:
That exact test is not working, giving:
Failed asserting that null matches expected 'someplate'
Even though it works if I manually create that vehicle in the actual page.9 replies
App Dropdowns full width
All dropdowns of the app are "full width", actually they are with a strange positioning.
I've tried filament:upgrade, npm run dev, npm run build, remove node_modules... nothing worked.
I do not have a custom theme or any custom css
I have this bit of code in the AdminPanelProvider, to handle the hot reload:
5 replies
Repeater with MorphTo relationship don't work on create page
I have a polymorphic model "Content", and the possible entities "ContentVideo" and "ContentQuiz" for example.
in the "ContentResource" I have this form with a repeater, relating to the models "QuizQuestion" and "QuizOption".
so, "Content" morphsTo "ContentQuiz", "ContentQuiz" hasmany "questions", and "ContentQuestion" has many "options"
This repeater works on the edit page, but not on the create page, I get the error:
If a add a
->model(ContentQuiz)
in the Repeater
chain, it works on the create page, but stops working in the edit page1 replies
Create related record inside infolist
How can I create a record of another model inside a infolist using an action button?
I have a infolist in my "BookingResource", I want that button to create a "Invoice" (Booking and Invoice are related), how can I do that? with a modal if possible.
I'm trying to do something like this but it's not working:
The motive is that I need the booking to have a invoice featured before I can complete the booking, if there's a better a way to do this, let me know
7 replies
How to test Infolist Action?
I have a infolist with a ActionsGroup, I want to test if those buttons are working, but I can't figure out how to trigger those actions in the tests. (they work normally in the app)
Infolist Action:
Test:
With that test I get:
The button does exists in the test because I "assertSee" it and it passes, but I cannot call it's action
21 replies
Count same relationship in multiple columns
I want to have some columns counting the same relationship, but with a few differences, such as different status. For example:
both of these columns work when used alone, but they don't work together (there's no error, they just don't show data). I tried using one of them as "sum" or changing the "make" name, but I could not make it work, I'm reading the docs but I can't find a best practice solution for that
2 replies
How can I test a form from a modal? (simple resource)
I have some resources made with --simple flag, so they don't have
Create
, Edit
or View
pages, only the Manage
class. I would like to know 2 things, how to assert the modal rendering and how to test the form (because the fillForm
seems to not work in this case).
1 - is this a good assertion for the "render modal test"?
2 - how to use the fillForm for modals?
9 replies
Handling Model Deletion with onDelete('restrict')
I set onDelete('restrict') in my model migration to prevent deleting records with active relationships. However, I still face an "Integrity constraint violation" error when attempting deletion. How can I handle this to stop the error and notify users that they can't delete records with active relationships?
5 replies
Input field inside repeater don't work / get validated correctly
I have a simple "quantity" field inside a repeater, I tried to use:
->integer()
->gt(0)
->minValue(1)
but those validations don't work, I can still set a number less than 0, even using the arrows (for the "minValue" method), and I don't get any errors on the submit (for the "integer" and "gt" validations). If I put that same input outside the repeater, it works...1 replies