1

In Sitecore 9.0, when I create a Droplink or Droplist Sitecore generates a "blank" selection. For example I have a Droplink from Monday to Sunday, the first option will be a blank selection.

How can we remove this blank selection?

  • I'm afraid you can't. That would mean that you cannot clear selection. And what is more, what should be the default value then? Which one should be selected by default? – Marek Musielak Aug 1 '19 at 15:05
  • You can select a default value from the data-source. However, the business user can still select the blank value. – Ercan Polat Aug 1 '19 at 15:16
  • 2
    I would recommend setting a field validation so that the content author gets a warning (or error) if they leave it empty (i.e. select the blank option). briancaos.wordpress.com/2011/05/09/… – Dan Sinclair Aug 1 '19 at 15:18
  • There are two workarounds to handle this but I would like to remove the blank field. First workaround is to add required field validation. If the user selects a blank and tries to save a popup message displays. The business user needs to select a value. I did not like this workaround. – Ercan Polat Aug 1 '19 at 15:18
  • The second workaround is that to select a checkbox on the template to reset to the default value. If the business user selects a blank value and saves the droplist automatically resets to default value. I liked this workaround more. – Ercan Polat Aug 1 '19 at 15:20
2

Unfortunately, you cannot completely remove the blank option. Instead, I would recommend setting the Required field validator on your field so that a user gets a warning (or cannot save it) if they leave the field blank.

Add the validator

  1. In the Content Editor, select your field item in Sitecore
  2. Scroll down to the Validation Rules section and add the Required item to all four validation fields:

    validation rules fields

  3. Save your field

Extra credit: prevent the editor from saving

If you want to prevent content authors from saving the item at all if there is no value selected, you can create a copy of the default Required validator and increase the error level of its failures.

  1. In the Content Editor, select the Required field validator
    • /sitecore/system/Settings/Validation Rules/Field Rules/Required
  2. Copy the item to a folder of validation rules you manage
  3. In the Parameters field, add Result=FatalError
  4. Add this new validator to your field instead of the default Required validator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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