API page: http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.ht...

During testing, I found that if #default_value is not specified, or is set to NULL, AND #required is set to TRUE, an item is added at the top of the select list with the name " - Select - "

If it is not a required field, you do not get this item.

Comments

jhodgdon’s picture

Project: Drupal core » Documentation
Version: 7.x-dev »
Component: documentation » API documentation files
Issue tags: +FAPI reference

Moving to correct issue queue (this file is in the Documentation project git repository).

jn2’s picture

Title: Form API Reference: "Select" documentation incomplete » Form API Reference: "Select" documentation hard to find
Status: Active » Fixed

This is actually thoroughly documented in the FAPI reference but is hard to find. The following statement I added to the select element should fix this problem (for both D7 and D8).

"See #empty_option and #empty_value for an explanation of various settings for a select element, including behavior if #required is TRUE or FALSE."

Unfortunately, something about api.d.o is broken, and this commit won't appear until it's fixed.

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