New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support nested relational values in conditional fields #8228
Comments
At first look, it seems you are not using the right filter. |
It is exactly what I want in this case. I need to show fields only for a certain item on an other collection. |
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. |
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]") |
I tried this solution but it doesn't work on version 9.8.0. My problem is the same as the OP |
@ulvidamirli This is an open issue 👍🏻 If there's any updates to this setup, you'll hear about it here first 🙂 |
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? |
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) 👍🏻 |
Well, looks like I have a meeting set up with Kendyl and Rob tomorrow at 3 to discuss sponsoring this work 🙂 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
Linear: ENG-291 |
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! |
@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 👍 |
@rijkvanzanten I see, understood! Thanks for the heads up on |
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) |
Notes from Request Review Feb 22, 2024:Three considerations:
Brain storming:
Scope Back Down:
|
Preflight Checklist
Describe the Bug
My test case is, that I want to hide a field if there is a item selected in a
m2m
relation:To Reproduce
name
to Collection Aname
:name
should 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
The text was updated successfully, but these errors were encountered: