You are here

function webform_localization_form_webform_component_edit_form_alter in Webform Localization 7.4

Same name and namespace in other branches
  1. 7 webform_localization.module \webform_localization_form_webform_component_edit_form_alter()

Implements hook_form_FORM_ID_alter().

Add specific localization options to Webform Component Edit Form.

File

./webform_localization.module, line 775
Webform localization module.

Code

function webform_localization_form_webform_component_edit_form_alter(&$form, &$form_state, $form_id) {
  $component = $form_state['build_info']['args'][1];
  if (!isset($component['cid'])) {
    $component['cid'] = -1;
  }

  // Gets webform localization options that match this node ID.
  $webform_localization_options = webform_localization_get_config($component['nid']);
  if ($webform_localization_options['sync_components']) {
    if (!module_exists('translation')) {

      // Enable the translation module as it is needed for localization sync.
      module_enable('translation');
    }
    module_load_include('inc', 'webform_localization', 'includes/webform_localization.component.sync');
    $select_options = webform_localization_synchronizable_properties($component);
    $form['localization'] = array(
      '#type' => 'fieldset',
      '#title' => t('Localization by Sync / Component settings'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#weight' => -4,
      '#description' => t('Here you can specified what properties need to be sync for thiscomponent across the several nodes in a translation set. If youare seeing this means that you have enabled the <em>"Synchronizewebform components across node translations"</em> option in thewebform that contains this component.', array(
        'html' => TRUE,
      )),
    );
    $form['localization']['standar_properties'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Select properties to synchronize across translations.'),
      '#options' => $select_options['standar'],
      '#default_value' => $select_options['standar_values'],
      '#description' => t('Common properties that applies to all types of components.'),
    );
    $form['localization']['extra_properties'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Select especial properties to synchronize across translations.'),
      '#options' => $select_options['extra'],
      '#default_value' => $select_options['extra_values'],
      '#description' => t('Special properties that applies only for this type of component.'),
    );

    // NOTE:
    // First we save the sync options to know what to do with the changes.
    array_unshift($form['#submit'], '_webform_localization_webform_component_edit_form_submit');
  }
}