6

I am working with Sitecore 8.1 and I am having a strange issue.

I have a General Link field called 'Login Link' on which I am trying set required field validation. I have selected 'Required' for all the validation rules section in the template for that field such as :

  • Quick Action Bar
  • Validate Button
  • Validator Bar
  • Workflow

Screenshot from validator bar section is given below:

enter image description here

However, when I go to the item that uses this template, I do not see Validator Bar for the Login Link field when the value is blank. Since I have Required selected in validator bar, I was expecting to see a red validator bar if the item fails validation. However, I do not see the validator bar when the item fails the validation. It does show up for the other field which is a rich text field.

Am I missing any step in this process? Please let me know!

Thanks,
Akshay


UPDATE - 10/06/16

I did a little more digging into it and it turns out that only the first item that fails validation was getting the validator bar. When I moved my Login Link field to be the first item in my template, it did give me a validator bar. Please see the screenshot below:

enter image description here

Hope this helps!

3 Answers 3

9

The question update is your answer. That's standard behaviour of Sitecore. You should also see red squares on the right top. enter image description here

There you can see all invalid fields as squares. It is not really visible but it is there... :)

Update

In Sitecore 8.2 update 1 it is fixed and they show you the validator bar for all invalid fields.

1
  • Yes, it looks like this is a standard behavior. For some reason, I always thought the default behavior was to highlight all the errors with the validator bar. Thanks for clarification :) Commented Oct 7, 2016 at 13:18
1

The Sitecore RequiredFieldValidator checks to see if the supplied field value is null or empty.

With XML-type fields (General Link fits in this type) this validator seldom works because merely accessing and/or saving the field without supplying a value will create some framing XML that will pass the string.IsNullOrEmpty() test.

To see this at work, enter the Content Editor. On the VIEW tab, switch to "Raw Values" - You will see the XML in the field that you thought was empty!

You should write your own validator that checks each of the individual attributes of this complex field type.

1

The only thing I can think of is non empty field value.

Turn on Raw Values and make sure that your General Link field is empty, otherwise you will not see Required validation bar (even if there is only white space inside).

I was able to create new template and everything works fine on my machine

Sitecore.NET 8.1 (rev. 160519)

If you want I can make a package with my template and example content item where validation bar is shown enter image description here

2
  • Interesting. I checked the raw values and it was empty. However, I found that other General Link fields in the Sitecore instance also showed the same behavior. I was wondering whether there was any instance specific settings that were governing this. Need to dig out more. Thanks for your responses though! Commented Oct 5, 2016 at 19:21
  • Could you please try the same (having general link as the second item in your template while the first item is also marked required) and let us know if you also see the same behavior? Thanks! Commented Oct 6, 2016 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.