You are here

function panopoly_magic_form_fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form_alter in Panopoly Magic 7

Implementation of hook_form_FORM_ID_alter()

File

./panopoly_magic.module, line 849

Code

function panopoly_magic_form_fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form_alter(&$form, &$form_state, $form_id) {

  // Setup the live preview
  if (variable_get('panopoly_magic_live_preview', 1)) {
    panopoly_magic_autosubmit_configure($form);

    // Special case exclusions for tablefield specific elements.
    if ($form_state['entity']->bundle == 'table') {
      $form['field_basic_table_table'][LANGUAGE_NONE][0]['tablefield']['rebuild']['count_cols']['#attributes']['class'] = array(
        'ctools-auto-submit-exclude',
      );
      $form['field_basic_table_table'][LANGUAGE_NONE][0]['tablefield']['rebuild']['count_rows']['#attributes']['class'] = array(
        'ctools-auto-submit-exclude',
      );
    }
  }

  // Add custom validation function for the reusable title
  $form['reusable']['admin_title']['#element_validate'][] = 'panopoly_magic_reusable_entity_validate';

  // Customize the view mode setting
  if (!empty($form['view_mode'])) {
    $form['view_mode']['#options'] = panopoly_magic_view_mode_options('fieldable_panels_pane');
    if (count($form['view_mode']['#options']) < 2) {
      $form['view_mode']['#type'] = 'value';
      $form['view_mode']['#value'] = key($form['view_mode']['#options']);
    }
    $form['widget_settings']['view_mode'] = $form['view_mode'];
    unset($form['view_mode']);
  }

  // Improving the general title setting
  if (!empty($form['widget_settings']['title'])) {
    $form['widget_settings']['title']['#size'] = '';
  }

  // Improving the link Options
  if (!empty($form['widget_settings']['link'])) {
    $form['widget_settings']['link']['path']['#size'] = '';
    $form['widget_settings']['link']['path']['#field_prefix'] = $form['widget_settings']['link']['path']['#title'];
    $form['widget_settings']['link']['path']['#title'] = '';
    $form['widget_settings']['link']['path']['#description'] = t('The URL or Drupal path from which to build the link.');
    $form['widget_settings']['link']['link']['#description'] = '';
  }

  // Move the reusable option to the general settings
  if (!empty($form['reusable'])) {
    $form['reusable']['#type'] = '';
    $form['reusable']['#title'] = '';
    $form['reusable']['reusable']['#title'] = t('Make this reusable');
    $form['reusable']['admin_title']['#field_prefix'] = t('Admin Title');
    $form['reusable']['admin_title']['#title'] = '';
    $form['reusable']['admin_title']['#size'] = '';
    $form['reusable']['admin_title']['#description'] = '';
    $form['widget_settings']['reusable'] = $form['reusable'];
    unset($form['reusable']);
  }
}