You are here

function i18nblocks_form_alter in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18nblocks/i18nblocks.module \i18nblocks_form_alter()
  2. 5 i18nblocks/i18nblocks.module \i18nblocks_form_alter()
  3. 5.2 i18nblocks/i18nblocks.module \i18nblocks_form_alter()

Implementation of block form_alter().

Remove block title for multilingual blocks.

File

i18nblocks/i18nblocks.module, line 120
Internationalization (i18n) submodule: Multilingual meta-blocks

Code

function i18nblocks_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'block_admin_configure' || $form_id == 'block_box_form' || $form_id == 'block_add_block_form') {
    $module = $form['module']['#value'];
    $delta = $form['delta']['#value'];
    $form['i18n'] = array(
      '#type' => 'fieldset',
      '#title' => t('Multilingual settings'),
      '#collapsible' => TRUE,
      '#weight' => -1,
    );
    $i18nblock = i18nblocks_load($module, $delta);
    $form['i18n'] = array(
      '#type' => 'fieldset',
      '#title' => t('Multilingual settings'),
      '#collapsible' => TRUE,
      '#weight' => 0,
    );

    // Language options will depend on block type.
    $options = array(
      '' => t('All languages'),
    );
    if ($module == 'block') {
      $options[I18N_BLOCK_LOCALIZE] = t('All languages (Translatable)');
    }
    $options += locale_language_list('name');
    $form['i18n']['language'] = array(
      '#type' => 'radios',
      '#title' => t('Language'),
      '#default_value' => $i18nblock->language,
      '#options' => $options,
    );

    // Pass i18ndelta value.
    $form['i18n']['ibid'] = array(
      '#type' => 'value',
      '#value' => $i18nblock->ibid,
    );
    $form['#submit'][] = 'i18nblocks_form_submit';
  }
}