drupal - How does one control select lists using form API? -


I know that this is a new question, but I am running in a deadline and a 3-day drupal experience Will not cut $ ... ['gender'] = array ('# type' => 'select', '# title' => t ('gender: *'), '# option' => array (t ( 'Men'), T ('women')), '#required' => TRUE, '#weight' => 2,);

How do I assign values ​​to values? For example, men -> 'm' and feminine-> 'f' How can I give a default caption to the selection box "Please select gender ..."

thanks guys

Try this:

  $ options = array ('', = & gt; 'Please select gender.', 'M' => 'Male', 'F' => 'Female',); $ Form ['gender'] ['# option'] = $ option;  

In your verification work (after submitting the form), you should ensure that the user is not a value that is not "".


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -