You are here

function panels_edit_display_submit in Panels 5.2

Handle form submission of the display content editor.

The behavior of this function is fairly complex and irregular compared to most FAPI submit handlers. See the documentation on panels_edit() for a detailed discussion of this behavior.

File

includes/display_edit.inc, line 223

Code

function panels_edit_display_submit($form_id, $form_values) {
  $display = $form_values['panels_display'];
  if ($form_values['op'] == t('Save')) {
    $old_content = $display->content;
    $display->content = array();
    foreach ($form_values['panel']['pane'] as $panel_id => $panes) {
      $display->panels[$panel_id] = array();
      if ($panes) {
        $pids = explode(',', $panes);

        // need to filter the array, b/c passing it in a hidden field can generate trash
        foreach (array_filter($pids) as $pid) {
          if ($old_content[$pid]) {
            $display->panels[$panel_id][] = $pid;
            $old_content[$pid]->panel = $panel_id;
            $display->content[$pid] = $old_content[$pid];
          }
        }
      }
    }
    drupal_set_message(t('Panel content has been updated.'));
    panels_save_display($display);
  }
  panels_cache_clear($display->did);
  if (empty($form_values['destination'])) {
    return $display;
  }
}