Umbraco-cms: Conditional logic for document types.

Created on 28 Sep 2018  路  7Comments  路  Source: umbraco/Umbraco-CMS

Add conditional logic for document types, to display properties based on a selection.

Simple example
Choose option 1 to display no property editor.
Choose option 2 to display 3 property editors
Choose option 3 to display 2 different property editors.

Real life example
Radio button 1 = "Default": Shows no property editors (Pulls default values)
Radio button 2 = "Custom": Property editors: Text String, Media Picker
-- Checkbox: "Expiry date": Property editor: Boolean = True
--IF TRUE-- Property editor: Date Picker

statuidea typfeature

Most helpful comment

I'd like to continue the discussion about this feature. I release the Conditional Displayers package to give this functionality. It uses jQuery and the 'data-element' property to show/hide properties. the truth is that it's pretty hacky.

Now I'm hitting a roadblock because the mandatory validation won't work, all the fields have to be non-mandatory for the package to work. I managed to toggle the validation in the frontend but Umbraco still checks on server side so it keeps giving validation errors.

The package has been downloaded around 1,500 times in 8 months, I personally think 1,501 (馃槃 ) people requesting this functionality is pretty high.

Question to Umbraco HQ: could this feature be part of the core?

All 7 comments

Something to add to that because I'm sure it will come up - I'd still want property validation to run on the condition that the property is not hidden away. So in the example above, if the selection was Custom then the additional properties would show, and would validated client-side and server-side.

If the value was Default both client-side and server-side would know, conditionally, this did not need to run through validation.

Wouldn't Nested Content be a solution for something like this?

@kjac Nested Content could be used for a temporary solution, but I don't see it as a solution in the long run.

I'd like to continue the discussion about this feature. I release the Conditional Displayers package to give this functionality. It uses jQuery and the 'data-element' property to show/hide properties. the truth is that it's pretty hacky.

Now I'm hitting a roadblock because the mandatory validation won't work, all the fields have to be non-mandatory for the package to work. I managed to toggle the validation in the frontend but Umbraco still checks on server side so it keeps giving validation errors.

The package has been downloaded around 1,500 times in 8 months, I personally think 1,501 (馃槃 ) people requesting this functionality is pretty high.

Question to Umbraco HQ: could this feature be part of the core?

It is on our list of ideas to look into in the future. We need to consider how this will work and indeed, validation is going to get a lot more complicated.

To set some expectations: we're not going to get to it in the near future.

@skartknet - That looks superb dude. I hope that HQ will look into this when they have the time for it.
Do you have an idea what it would take to support multiple choices (Select dropdown) for this package?

I thought about it, maybe I make it for a next version. But I guess that's a conversation to have in a different channel. Feel free to post in the package forum.

Was this page helpful?
0 / 5 - 0 ratings