ideas
ideas copied to clipboard
Add field path to custom condition functions
Consider this blueprint situation:
- replicator field
- set with a select field and another replicator
- within the nested replicator is a set with a text field
- the text field should be shown or hidden based on the input of the select field in its "parent" set
- this is currently not possible!
- so far we can refer to either fields on the same "nested level" or on the root blueprint level (via the
rootkeyword) (see here)
This is clearly a case for a custom condition function. However, so far custom condition functions get the following parameters: params, target, targetHandle, values, root, store, storeName, which still does not give any indication on where the current field would be in a nested structure.
Looking into the code it should be possible to pass on the field path (so the information as to where the currently observed field is) to a custom condition function, so I could add my own logic and consider every (upwards) relation. For the example above that would be pagebuilder.0.nested_replicator.0.inner_text_field. Using the store or the root object, this would allow me to access whatever level I would like to consider.
Have you seen https://github.com/statamic/cms/pull/9385?
Have you seen statamic/cms#9385?
Yes I had seen it, but actually forgot about it (fun fact: it was opened by one of my team members 🙈😄). Anyway, the approach in https://github.com/statamic/cms/pull/9385 only covers the "parent" case, while the approach of passing on the complete field path would allow for more than just one level up.
I mean, there would be nothing wrong with adding both if you'd ask me. The parent keyword would be more accessible and usable for simple field conditions, while adding the field path would extend the possibilities of custom functions.
Closed by statamic/cms#9385
Just added documentation as well here https://github.com/statamic/docs/pull/1502 👍