U4-10655 - Perplexing Validation of mandatory fields - textstring forces client side validation, textarea doesn't?

Created by Mike Chambers 08 Nov 2017, 16:49:18 Updated by Mike Chambers 09 Nov 2017, 17:19:14

Installed virgin 7.7.4 with the starter kit.. Added some more textstring and textarea into the content base composition set to mandatory. Tried creating a new "content page" textstrings show client side validation issues (but not textareas), so can't save/or publish...

According to issue #U4-6194 http://issues.umbraco.org/issue/U4-6194#comment=67-27756 "Content will be 'saved' if there are validation issues but won't be published."

If we fill in the textString, and save/publish then server side validation occurs showing the textarea issues too.. (and unpublished node created)

Is this just a simple one that for the functionality detailed in u4-6194 that no clientside validation can occur? So ng-required="model.validation.mandatory" needs removing from the \Umbraco\Views\propertyeditors\textbox\textbox.html

and possibly Umbraco\Views\propertyeditors\datepicker\datepicker.html Umbraco\Views\propertyeditors\email\email.html

It seems to be that works in the simple virgin 7.7.4 site that I have set up.. and any fields that are filled in get saved to the unpublished item but only on first submit to save/publish of the page, subsequent updates don't then save the updated field.

Would also possibly be nice to see the old message around content has been saved but not published? As well as the validation errors that seems to indicate nothing has happened in terms of node created or any fields that are filled in being updated.

3 Attachments

Comments

Sebastiaan Janssen 08 Nov 2017, 17:24:26

textstrings show client side validation issues (but not textareas), so can't save/or publish... Works for me? See screenshot.

"Content will be 'saved' if there are validation issues but won't be published."

That only goes for regex validations, not for mandatory fields. Mandatory is mandatory, can't save without filling them in. See second screenshot, the value saved but can not be published.

If we fill in the textString, and save/publish then server side validation occurs showing the textarea issues too.. (and unpublished node created)

Aha, yes, I can confirm: create new page with textstring AND textarea that are both mandatory, you can fill in textstring field, then when you try to save/publish the page returns with an error that textarea needs to be filled in. It works, but it's not pretty.

any fields that are filled in get saved to the unpublished item but only on first submit to save/publish of the page, subsequent updates don't then save the updated field.

This I cannot reproduce. Yes, if you clear out a mandatory field, nothing will get saved. The field is mandatory, it requires content. So changes elsewhere will not get saved either until you correct the mandatory field.

be nice to see the old message around content has been saved but not published

If content gets saved, it says to remember to publish (screenshot 3).


Mike Chambers 08 Nov 2017, 18:44:17

@sebastiaan Thanks for coming back to me so quick, and qualifying the distinction between mandatory and a validation rule,, though isn't mandatory simply a not null validation ;-)

So point one.. what I meant was.. if I create new content.. mandatory textstring and textarea, if I don;t fill in the textstring.. hit submit no action taken stopped in it's tracks client side and no content node created.. see only the mandatiory validation error for the textstring.

If I then fill that textstring in still leaving the mandatory textarea blank.. then page submits to server and get the validation message on the textarea... but I now have an unpublished node created, even though textarea is mandatory?

point 3.. if I end up with that unpublished node.. navigate away, come back to it.. update the textstring to a different non null value.. hit save/publish then the textstring gets updated.. but if I try and update again without hard refreshing no changes to the textstring then save. And I've still here managed to save/update with mandatory textareas being empty (which you said shouldn't happen).

last point.. was meaning in the scenario that I have these part filled nodes failing validation.. but some changed items updating.. would like to see the even though not published changes were saved.. I agree once all validation passed and save used.. see the message you have posted..

Hope this clears up the issue I;m having where by mandatory on these text fields doesn't mean no node can be created..

Also as I said if you remove the ng-required on the textstring view, (it's not present on the textarea view) you can now get the same funct that seeing on the textarea even though mandatory set textarea is empty, unpublished nodes are created.. guessing but removing that stops the client side validation.. and once able to submit to the server validation.. we can get unpublished nodes created?


Mike Chambers 09 Nov 2017, 16:29:26

Had a further look into this.. and flipping it on it's head, if mandatory does mean no save or submit.. Last commit of src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.html into the v7.7 branch

https://github.com/umbraco/Umbraco-CMS/commit/17969e453779e61a0d4770202004581e041eb886#diff-95285976fbc2917ab3afc822226cb05f

seems to be that ng-required="model.validation.mandatory" was removed? (wasn't removed from textbox when maxchars also added to it)

Maybe that's the source of my consternation, and it's just limited to textAreas and not generic validation?


Mike Chambers 09 Nov 2017, 17:19:14

or maybe the consistent approach is to use the valPropertyValidator ??

// Method required by the valPropertyValidator directive (returns true if the property editor has at least one tag selected)

$scope.validateMandatory = function () {
                return {
                    isValid: !$scope.model.validation.mandatory || $scope.model.value != null && $scope.model.value.length > 0,
                    errorMsg: 'Value cannot be empty',
                    errorKey: 'required'
                };
            };


Priority: Normal

Type: Bug

State: Submitted

Assignee:

Difficulty: Normal

Category: Editor

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.7.4

Due in version:

Sprint:

Story Points:

Cycle: