Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
(Sorry if this is the wrong category; I can't seem to figure out how to put it in Extending Umbraco and Using the API)
I'm working on a custom Conditional Logic property editor that essentially holds conditional logic for other properties of a specific element or content type. Without going into too much detail on the context, here's what's going on:
The Conditional Logic configuration includes:
For example, show the Circumference property and make it mandatory if the Shape property value is equal to "Circle":
Which means that Circumference is hidden and not mandatory when the Shape selected is something other than Circle:
I've only used this on element types (in a block list) so far.
The problem I'm running into is with conditionally mandatory fields. I've been able to get a jQuery object of the correct umb-property element, and I'm able to use this to modify the mandatory property:
propertyElement.scope().property.validation.mandatory = isMandatory;
This successfully toggles the visual appearance, but for some reason setting mandatory to true seems to break the client-side validation of the entire block, even for other properties that have not been directly modified. (The Conditional Logic property editor JS does also call $setInvalid on the conditionally required property when the form is submitting, but I've confirmed that setting the mandatory property to true is definitely what's causing the issue.)
For example, if there's a textbox property with a value that exceeds its character limit, and it's in the same block as a property that has been dynamically changed to mandatory, then the Save and Publish will go through without showing errors for either property.
This appears to be a result of the invalid and valid states not being propagated up to the form correctly:
Can anyone think of why this might be breaking the client-side validation of the whole block, or whether there's a safer way to modify whether a property is mandatory on just the client side? (If I just change that property to mandatory in the settings, then it's still mandatory and will be caught by server-side validation even when it should be hidden.)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted