Default values for showCreateRelationButton #5711
Unanswered
JeroenHauser
asked this question in
Ideas & Feature Requests
Replies: 1 comment
-
|
Suggestion: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, first: thanks for developing and maintaining Nova actively, it's been a great help in quickly setting up a CRUD admin panel. For most of my questions I can find the answer in the docs or somewhere on the web. Also love the community support.
Now I think I stumbled on what would be a feature request. I'd like to pass default values via the showCreateRelationButton method on a BelongsTo field in my Resource.
This is the case why:
I'm developing a small reservations platform for an indoor child playground. Central here are Families. Then we have Children that belong to a Family, Families have many Children. And Reservations that belong to a Family, Families have many Reservations. When it's a child's birthday, we need to know for whose birthday the Reservation is for. So Reservations not only belong to a Family, but also belong to a Child, and Children have many Reservations (because of multiple birthday years). For maintaining all these Resources I use Nova.
We don't want admins to move Children from the one Family to another, that could become messy and is a privacy risk. But since admins must be able to see what Family a Child belongs to, the family_id BelongsTo field in the Child Nova Resource is readonly.
Now the admin is on a Reservation edit screen. The user forgot to / didn't provide a Child name in the reservation form and calls the service desk. The admin wants to create a Child from the Reservation edit screen. For this, I used the showCreateRelationButton method on the child_id BelongsTo field.
So when an admin click on the (+) button, the Child form modal opens, and... the family_id BelongsTo field is disabled! And in fact, I don't want the admin to be able to "choose" a Family for this new Child at all. There is only one possibility here: this new Child needs to belong to the same Family as the Family that made the Reservation (to what Family the Reservation belongs to).
This is why I need to provide default values when enabling this modal. Of course, the reservation_id will be filled automatically, since the admin is creating the Child from the Reservation edit form. But the family_id needs to be prefilled as well while not being editable by the admin.
Hope my feature request is clear and that this will end up on your roadmap! 😉
Beta Was this translation helpful? Give feedback.
All reactions