You are here

19 December 2011

This code snippet is about creating languages form field in Drupal 7 using field api.

Source code viewer
  1. global $language;
  2. $languages = array_keys(language_list());
  3. $form['language'] = array(
  4. '#title' => t('Language'),
  5. '#type' => 'select',
  6. '#options' => drupal_map_assoc($languages),
  7. '#default' => $language->language,
  8. '#required' => TRUE,
  9. );
Programming Language: PHP