Hi,

why don't you allow null (i.e. #isNullValid() returning true), while setting the DropDownChoice required?

That should give you the required placeholder option, doesn't it?

Regards
Sven


Am 01.04.2015 um 20:24 schrieb Thorsten Schöning:
Hi all,

I got the following error during validation of one of my forms today:

The first child option element of a select element with a required
attribute, and without a multiple attribute, and without a size
attribute whose value is greater than 1, must have either an empty
value attribute, or must have no text content. Consider either
adding a placeholder option label, or adding a size attribute with a
value equal to the number of option elements.
The message is about the following spec:

http://dev.w3.org/html5/spec-preview/the-select-element.html#placeholder-label-option

The reason for the error seems simple: I use a DropDownChoice with a
default selected value and null disallowed, so I always need a value.
In that case AbstractSingleSelectChoice.getDefaultChoice doesn't
provide any content, because there's already one value selected and
this is not null. That results in the select gets only rendered with
the choices provided, missing a default option with value "" and so
violating the HTML5 spec... The default option doesn't necessarily
needs to be selected, it just needs to exist if the select is
required.

To resolve this issue I extended DropDownChoice and implemented my own
getDefaultChoice, which simply always returns an option with value ""
if the base implementation returns an empty string.

Is this worth creating an issue in JIRA, either as bug or enhancement?

Mit freundlichen Grüßen,

Thorsten Schöning



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to