Most efficient way to have a 50 state drop down box in Drupal Forms -


I know that in a way there is a table in the database with all states and then you will read it in your form. Is there any easy way for people in your opinion?

I feel that doing something like this is bad because it is so elementary, but I think that something like simple will be implemented in Drupal already.

There is no need to hit the database, create yourself a task that is one of the states Returns the array.

$ form ['state'] = array ('#type' = & gt; select ',' #options' = & gt; Mymodule_states_list (), '# title' = & Gt; t ('state'),); Function mymodule_states_list () {Returns array ('AL' => 'Alabama', 'A' '>' Alaska ', ...' WY '=>' Wyoming ',); }

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 -