You are here

function panels_edit_display_form in Panels 7.3

Same name and namespace in other branches
  1. 6.3 includes/display-edit.inc \panels_edit_display_form()
  2. 6.2 includes/display-edit.inc \panels_edit_display_form()

Form definition for the panels display editor.

No validation function is necessary, as all 'validation' is handled either in the lead-up to form rendering (through the selection of specified content types) or by the validation functions specific to the ajax modals & content types.

See also

panels_edit_display_submit()

5 calls to panels_edit_display_form()
panels_change_layout in includes/display-layout.inc
Form definition for the display layout converter.
panels_layouts_ui::edit_form in plugins/export_ui/panels_layouts_ui.class.php
Provide the actual editing form.
panels_mini_ui::edit_form_content in panels_mini/plugins/export_ui/panels_mini_ui.class.php
panels_page_wizard_add_content in includes/page-wizard.inc
Add content editor form helper for panels page wizards.
panels_panel_context_edit_content in plugins/task_handlers/panel_context.inc
Present the panels drag & drop editor to edit the display attached to the task handler.
1 string reference to 'panels_edit_display_form'
panels_renderer_editor::edit in plugins/display_renderers/panels_renderer_editor.class.php
Display edit rendering.

File

includes/display-edit.inc, line 54
Core Panels API include file containing various display-editing functions. This includes all the basic editing forms (content, layout, layout settings) as well as the ajax modal forms associated with them.

Code

function panels_edit_display_form($form, &$form_state) {
  $display =& $form_state['display'];
  $renderer =& $form_state['renderer'];

  // Make sure there is a valid cache key.
  $cache_key = isset($display->cache_key) ? $display->cache_key : $display->did;
  $display->cache_key = $cache_key;

  // Annoyingly, theme doesn't have access to form_state so we have to do this.
  $form['#display'] = $display;

  // The flexible layout maker wants to be able to edit a display without
  // actually editing a display, so we provide this 'setting' to allow
  // that to go away.
  if (empty($form_state['no display settings'])) {
    $links = $renderer
      ->get_display_links();
  }
  else {
    $renderer->no_edit_links = TRUE;
    $links = '';
  }
  $form['hide']['display-settings'] = array(
    '#markup' => $links,
  );
  $form += panels_edit_display_settings_form($form, $form_state);
  $form['panel'] = array(
    '#tree' => TRUE,
  );
  $form['panel']['pane'] = array(
    '#tree' => TRUE,
  );
  $form['display'] = array(
    '#markup' => $renderer
      ->render(),
  );
  foreach ($renderer->plugins['layout']['regions'] as $region_id => $title) {

    // Make sure we at least have an empty array for all possible locations.
    if (!isset($display->panels[$region_id])) {
      $display->panels[$region_id] = array();
    }
    $form['panel']['pane'][$region_id] = array(
      // Use 'hidden' instead of 'value' so the js can access it.
      '#type' => 'hidden',
      '#default_value' => implode(',', (array) $display->panels[$region_id]),
    );
  }
  if (empty($form_state['no buttons'])) {
    $form['buttons']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#id' => 'panels-dnd-save',
      '#submit' => array(
        'panels_edit_display_form_submit',
      ),
      '#save-display' => TRUE,
    );
    $form['buttons']['cancel'] = array(
      '#type' => 'submit',
      '#value' => t('Cancel'),
    );
  }

  // Build up the preview portion of the form, if necessary.
  if (empty($form_state['no preview'])) {
    $form['preview'] = array(
      '#tree' => TRUE,
      '#prefix' => '<h2>' . t('Live preview') . '</h2>' . '<div id="panels-live-preview">',
      '#suffix' => '</div>',
    );
    ctools_context_replace_form($form['preview'], $display->context);
    $form['preview']['button'] = array(
      '#type' => 'submit',
      '#value' => t('Preview'),
      '#attributes' => array(
        'class' => array(
          'use-ajax-submit',
        ),
      ),
      '#id' => 'panels-live-preview-button',
      '#submit' => array(
        'panels_edit_display_form_submit',
        'panels_edit_display_form_preview',
      ),
    );
  }
  return $form;
}