Unable to use BelongsTo::relatableQueryUsing on resource created inline from another resource. #6237
Replies: 6 comments 1 reply
-
Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example) |
Beta Was this translation helpful? Give feedback.
-
Added: https://github.com/davidbankes/nova-inline-creation There's an sql dump in the storage folder, too. I've kept it pretty simple. There's one proposal that two users are collaborating on. The proposal has a requirement, and I want to inline create a document on that requirement. (A document is a file that belongs to a user). I only want the available users to the the users collaborating on the proposal the requirement belongs to. But Nova doesn't give me the information I need to build that filter. I can inline create the document if I don't filter the users, but I want the administrator working on the proposal to only be able to go through the users associated with the proposal. If you use the SQL dump to get started, the password for all users is |
Beta Was this translation helpful? Give feedback.
-
Any progress here? I'm interested in this and was running into the same issue |
Beta Was this translation helpful? Give feedback.
-
@crynobone Is there more information you need to evaluate this? I think the "Needs more info" label is incorrect. If there's something more you need, let me know and I'll get it to you. |
Beta Was this translation helpful? Give feedback.
-
This also applies to a BelongsToMany resource. I can get the button to show up, and theoretically I should be able to filter with |
Beta Was this translation helpful? Give feedback.
-
That's available at the moment is according to the expected behavior, moving this to Idea & Feature Request so we can look into this again in the future. |
Beta Was this translation helpful? Give feedback.
-
Description:
Can't use BelongsTo->dependsOn or ->relatableQueryUsing on a resource that can be created via an inline creation button from another resource
Detailed steps to reproduce the issue on a fresh Nova installation:
Models & relations diagram:
User
->belongsToMany Proposals
->hasMany Documents
Proposal
->belongsToMany Users
->hasMany Requirements
Requirement
->belongsTo Proposal
->belongsTo Document (inline creation enabled)
Document
->belongsTo User
->hasOne Requirement
When I'm in a Proposal->Requirement resource, I have a select dropdown to associate a document with it, or I can create a document inline. If I create it inline, I want to be able to only select one of the users associated with the Proposal that the requirement I'm editing belongs to. Based on https://nova.laravel.com/docs/4.0/resources/relationships.html#relatable-query-filtering, I should be able to using a dependent field to do this... make the user field dependent on the requirement field, and then only allow users associated with the proposal whose requirement I'm editing, but I can't make it work.
Also, the documentation linked to above seems pretty much identical to https://nova.laravel.com/docs/resources/fields.html#accessing-request-resource-ids. If I could access the resource ID of the requirement, I'd be home free, but I can't
The URL used for getting the creation fields for the inline creation modal is
http://example.test/nova-api/documents/creation-fields?editing=true&editMode=create&inline=true&viaResource=&viaResourceId=&viaRelationship=
. Shouldn't this include the relevant relationship information? (Understandably, if I was creating a new Requirement, then there'd be no ID to pass, and that's a different problem, but since I'm editing an existing Requirement, shouldn't that information be passed to the creation-fields URL?Beta Was this translation helpful? Give feedback.
All reactions