Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292538

Provide default value for select option when no value was previously selected

$
0
0

When there is no saved value for a select list, drupal does not set a default value.
This is fine in most circumstances, however, if the select list is ever sorted by a method other than the default ordering, the "- None -" value is not preselected.

To reproduce:
In a form alter for a node edit form, call asort() on a field's option list. This drops the "- None -" option lower in the list.
Choose the "- None -" option and save the form.
On reloading the form, the first element on the list will be preselected, not because of the selected attribute, but simply because it is the first element in the list.

Patch supplied to set the default value of the list to "- None -" when no saved value is found.


Viewing all articles
Browse latest Browse all 292538

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>