You are here

function hidden_language_form_alter in Hidden Language 7

Implements hook_form_alter().

File

./hidden_language.module, line 104

Code

function hidden_language_form_alter(&$form, &$form_state, $form_id) {
  if (!in_array($form_id, array(
    'locale_languages_overview_form',
    'language_hierarchy_form',
  ))) {
    return;
  }
  $languages = language_list();

  // Initialise checkboxes array.
  $options = $hidden = array();

  // Iterate through each database result.
  foreach ($languages as $item) {

    // Create list of hidden languages and the language checkboxes options for later use.
    $options[$item->language] = '';
    if ($item->hidden) {
      $hidden[] = $item->language;
    }
  }
  $form['hidden'] = array(
    '#type' => 'checkboxes',
    '#title' => 'Hidden languages',
    '#title_display' => 'invisible',
    '#options' => $options,
    '#default_value' => $hidden,
    '#printed' => TRUE,
  );
  array_unshift($form['#submit'], 'hidden_language_form_submit');
}