I think you should remove the "No value" value for a select element has the possibility to indicate "Empty Option"

Comments

guignonv’s picture

Status: Active » Needs review
StatusFileSize
new2.32 KB

Try this patch, it should not add "No value" when component is required.
Note: when not required, the "No value" item is added at the end of the list. Maybe that list should be alphabetically sorted and "No value" added at the top?

Status: Needs review » Needs work

The last submitted patch, 1: webform_references-no_value_is_unnecessary-2493835-1.patch, failed testing.

cmedina’s picture

In my opinion, it would be better to indicate the property "#empty_option" and property "#empty_value" in the "select" element. I think "No value" should never be added (it is independent of whether the field is defined as mandatory or not).

  • sumitmadan committed 790d300 on 7.x-1.x
    Issue #2493835 by cmedina: No value is unnecessary
    
sumitmadan’s picture

Status: Needs work » Fixed

Thanks cmedina,
I have committed the code with `#empty_option' to dev branch . :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

yaach’s picture

I dont see the feature @cmedina proposed. I have downloaded current and dev versions. I still have the "No Value" option.

In my case I have a Node Reference field which is not required. I would prefer a "Select Option" for empty option rather than "No value".

Anyway, could you describe how to get the 'EMPTY OPTION'

Thanks.

yaach’s picture

Status: Closed (fixed) » Needs review
sumitmadan’s picture

Status: Needs review » Closed (fixed)

Hi @yalegria,

I have added '#empty_option' => t('No Value'), to form element instead of adding "no value" to options array. So if you want to replace "No Value" then please use String Override module or use hook_form_alter way.

yaach’s picture

Hi @sumitmadan,

I actually wanted the same "Empty option" implemented on the webform select list component, where if the field is required then "Select" would be the default option; and if the field is NOT required the default option would be "None".

I have ported this to webform_references and created a patch.

yaach’s picture

Status: Closed (fixed) » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: webform_references-select_empty_option-2493835-10.patch, failed testing.

Chewits’s picture

By the way, why not to rename "No Value" to "- None -"?

When I use a field of type "Term reference" for User entity with widget "Select list", the list of terms is rendered with "- None -" item.
When I try to use the same vocabulary in a Webform it shows "No Value".. Let's use the same word "- None -".

To be more exacts:

"Term reference" field is rendered as:

...
<option value="_none">- None -</option>
...

The same item on Webform:

...
<option value="">No Value</option>
...
joel_osc’s picture

Version: 7.x-1.5 » 7.x-1.8
Category: Task » Bug report
Status: Needs work » Needs review

Updating the version reference in the case, setting as a defect to make consistent with other Drupal selects and setting back to needs review for the bots - patch looks good, nice work on it!

sumitmadan’s picture

Status: Needs review » Fixed

Thank you all for you efforts. I have committed and pushed the changes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.