Support nested relational values in conditional fields #24919
Replies: 20 comments 1 reply
-
|
At first look, it seems you are not using the right filter. |
Beta Was this translation helpful? Give feedback.
-
|
It is exactly what I want in this case. I need to show fields only for a certain item on an other collection. |
Beta Was this translation helpful? Give feedback.
-
|
I think you're running into #7123 The problem currently is that the app form itself only contains the "top level" field values (what you'd get from the api with the default When the user edits the value, the value will now exist, which in turn allows the condition to work, but then there's an interesting divide between "select existing" and making edits to the nested item. When the user selects an existing relational item, the staged value from the app will be the primary key of the related (what you're currently using in your condition as well), though when the user edits that item, the staged value will turn into an object with the changes applied. Long story short: right now conditional fields doesn't support nested relational fields reliably, though I agree you'd expect it to work the same as regular filtering setup. |
Beta Was this translation helpful? Give feedback.
-
|
We can solve for the missing data on load by keeping track of a special "Conditional values" object on first load of the item, which uses the filter object to deconstruct what data is needed on load. That will solve for the missing data on first load problem. The second problem is a little more difficult to solve for, as there's 2 different "shapes" we expect to exist in the lifecycle of the page. Either we require the user to configure two conditions (for example "ITEM = 5 OR ITEM.ID = 5"), or we figure out some way to do that a little smarter ("if condition is string/number, compare to item[primarykey]") |
Beta Was this translation helpful? Give feedback.
-
I tried this solution but it doesn't work on version 9.8.0. My problem is the same as the OP |
Beta Was this translation helpful? Give feedback.
-
|
@ulvidamirli This is an open issue 👍🏻 If there's any updates to this setup, you'll hear about it here first 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
Running into this now, and it's a pretty big problem for me, I have a "configuration" table that has rules for which fields to show. I understand that only top level fields are selected on form load, but wouldn't it make sense to hydrate the form with the related fields when the user selects the relation? |
Beta Was this translation helpful? Give feedback.
-
No, cause it changes the data structure of the input data for the individual interfaces, and therefore hinders the data that's available for sub-fields in drawers and the like. It used to work like that in v8 actually, and caused massive issues around nested relational data editing 🙂 That being said, yes, it should fetch the nested relational data that is used in the conditions (but not in the whole form context) 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
|
Well, looks like I have a meeting set up with Kendyl and Rob tomorrow at 3 to discuss sponsoring this work 🙂 |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
This comment has been hidden.
This comment has been hidden.
-
|
Linear: ENG-291 |
Beta Was this translation helpful? Give feedback.
-
|
Are there any updates on this, please? I've just been following this tutorial (https://www.youtube.com/watch?v=AqBYC39Nu2c&list=PLUBR53Dw-Ef9ZRA0QkaSKlcpotqbzQSv0&index=7) to get a feel for the CMS and its capabilities, and while you see the host encountered their own issues which can be attributed to an earlier version of Directus, my issue is that I'm not getting relational fields appearing in the dropdown at all, which the reasoning for has been mentioned here #15300. So, when I edit the raw value to build my own, I've tried the following according to this #11920 (comment), so: and: Neither seem to be working. I'm currently looking for a go-to CMS for my own projects and I've enjoyed my experience with Directus up to now. Is it likely to be fixed in the near future? This was first raised in Sep 21, and we're Mar 23 now, I'm just curious how high up on the priority list this is i.e. did you ever manage to get sponsorship for this one. Cheers! |
Beta Was this translation helpful? Give feedback.
-
|
@curtisburns
This doesn't really mean anything! There's issues that have been open longer that most likely won't be resolved any time soon, and issues that are raised more recently that are resolved already. It's not a first-in-first-out system 👍🏻 As for timelines, the only thing I can leave you with is our default blurb around estimates in open source issues: Unfortunately, we can not provide estimates on features or fixes. As of now, the only way to get an accurate timeline or release date is to sponsor this task. We recognize that this may be an important feature/fix, but we are a small open-source organization with a lot to triage and complete. If you can't sponsor this ticket, then the next best thing is to increase its priority by giving it a 👍 |
Beta Was this translation helpful? Give feedback.
-
|
@rijkvanzanten I see, understood! Thanks for the heads up on |
Beta Was this translation helpful? Give feedback.
-
|
On February 22 we're inviting you to come and have a chat with us about this feature request at our Request Review in our Discord server. This will help us have some dedicated time to talk about what implementation would have the most sense. Please feel free to join us as https://directus.chat/ (the event is already listed and you can set a reminder) |
Beta Was this translation helpful? Give feedback.
-
Notes from Request Review Feb 22, 2024:Three considerations:
Brain storming:
Scope Back Down:
|
Beta Was this translation helpful? Give feedback.
-
|
I currently work around this with a set of custom extensions. However, the solution is more brittle than I'd like, and I would prefer to resolve the issue the Directus way. Also, we have to create a new extension for every collection that requires this type of nested collection conditional display of fields, which is not ideal. If there were a way to add an alias for a given field within a translation collection that updated live when the parent value updated in the UI, for example, we could use the existing conditions feature to affect the changes we need in the UI. |
Beta Was this translation helpful? Give feedback.
-
|
any updates on this ? |
Beta Was this translation helpful? Give feedback.
-
|
Also would love this. 👀 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Preflight Checklist
Describe the Bug
My test case is, that I want to hide a field if there is a item selected in a
m2mrelation:To Reproduce
nameto Collection Aname:nameshould be hidden if the condition matchesWhat version of Directus are you using?
v9.0.0-rc.93
What version of Node.js are you using?
v14.17.5
What database are you using?
MySQL 8
What browser are you using?
Chrome
What operating system are you using?
Windows
How are you deploying Directus?
Linux VPS
Beta Was this translation helpful? Give feedback.
All reactions