You are here

function form_builder_custom_formatters_form_alter_alter in Custom Formatters 7.2

Implements hook_custom_formatters_form_alter_alter().

File

includes/form_builder.inc, line 11
Form Builder module integration.

Code

function form_builder_custom_formatters_form_alter_alter(&$form, &$form_state, $form_id) {
  if (in_array($form_id, array(
    'ctools_export_ui_edit_item_form',
    'ctools_export_ui_edit_item_wizard_form',
  )) && isset($form['#formatters']) && isset($form['engine']['settings'])) {
    if ($form_state['op'] == 'add' || $form_state['op'] == 'edit' && !custom_formatters_formatter_is_active($form_state['item'])) {
      drupal_add_css(drupal_get_path('module', 'custom_formatters') . '/styles/custom_formatters.form_builder.css');
      $form['engine']['settings'] = array(
        '#type' => 'fieldset',
        '#title' => t('Formatter settings'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#tree' => TRUE,
      );
      module_load_include('inc', 'form_builder', 'includes/form_builder.admin');
      module_load_include('inc', 'form_builder', 'includes/form_builder.api');
      module_load_include('inc', 'form_builder', 'includes/form_builder.cache');
      $form_type = 'custom_formatters';
      $form_id = drupal_substr($form['#build_id'], 0, 32);

      // Set the current form type (used for display of the sidebar block).
      form_builder_active_form($form_type, $form_id);

      // Load the current state of the form.
      $form_structure = _custom_formatters_form_builder_load_form($form['#item'], $form_id);
      $form['engine']['settings']['preview'] = form_builder_preview($form, $form_state, $form_structure, $form_type, $form_id);
      $form['#submit'][] = 'custom_formatters_form_builder_submit';
    }
  }
}