kgiszewski / uWestFest

Slides and Code from our uWestFest talk on Property Editors
7 stars 14 forks source link

Control does not honor "Mandatory" setting #14

Open lcichanowicz opened 10 years ago

lcichanowicz commented 10 years ago

Unfortunately, this control does not honor Umbarco's "Mandatory" setting for properties. This causes grief for the developer who uses the control, because I have to perform a "check" to ensure that I get Umbraco to render a URL without a YSOD due to having an empty TypeData.Url, or .ContentId, or .MediaId.

kgiszewski commented 10 years ago

It does not simply b/c what does 'Mandatory' mean in the context of several inputs? Does it mean you need a URL only? A URL and a Title?

lcichanowicz commented 10 years ago

Wow, thanks for the quick reply! It's a Url Picker, so it means there must be a URL. :]

Due to how the control works, basing the persisted "type" value on the active tab when saved, it should mean that the active tab's "url" input must be populated.

My Umbraco property (field) is required. If I can't enforce mandatory, I can't use the control. :[

kgiszewski commented 10 years ago

I haven't been able to dig into the Umbraco core to find out or not, but I think the Mandatory field simply looks for any value being present. You could try a regex validation instead. I.e. make sure the JSON that stores the URL has a value between the "'s

lcichanowicz commented 10 years ago

Oh, so maybe Mandatory is being satisfied by the "empty" JSON text in the field when the "URL" inputs are all empty? That could make sense, even though it's still a problem.

I cannot help wondering how the inspiring uComponents URL Picker handles mandatory.

tomfulton commented 10 years ago

As of 7.1.0 propertyeditors can determine if they're marked as required - maybe we can check for this flag and fail our own validation if so? (Though I don't think we have any validation currently)

mhughes4 commented 6 years ago

Hi, I have a solution which validates on the link. It checks to see if a link has been chosen, providing that the linkpicker is set to be mandatory in umbraco. However, it does not check to see if a title has been provided. I was thinking of raising a PR for this if anyone thinks that this will be of use?