Contributions API

i18nsync_form_alter

Definition

i18nsync_form_alter(&$form, $form_state, $form_id)
contributions/i18n/i18nsync/i18nsync.module, line 55

Description

Implementation of hook_form_alter().

Code

<?php
function i18nsync_form_alter(&$form, $form_state, $form_id) {
  // Taxonomy vocabulary form
  switch ($form_id) {
    case 'node_type_form':
      $type = $form['#node_type']->type;
      $current = i18nsync_node_fields($type);

      $form['workflow']['i18n']['i18nsync_nodeapi'] = array(
        '#type' => 'fieldset', '#tree' => TRUE,
        '#title' => t('Synchronize translations'),
        '#collapsible' => TRUE,
        '#collapsed' => !count($current),
        '#description' => t('Select which fields to synchronize for all translations of this content type.')
      );
      // Each set provides title and options. We build a big checkboxes control for it to be
      // saved as an array. Special themeing for group titles.
      foreach (i18nsync_node_available_fields($type) as $group => $data) {
        $title = $data['#title'];
        foreach ($data['#options'] as $field => $name) {
          $form['workflow']['i18n']['i18nsync_nodeapi'][$field] = array(
            '#group_title' => $title,
            '#title' => $name,
            '#type' => 'checkbox',
            '#default_value' => in_array($field, $current),
            '#theme' => 'i18nsync_workflow_checkbox',
          );
          $title = '';  
        }     
      }

      break;
  }      
}
?>