1 layout.admin.inc layout_content_form_submit($form, &$form_state)

Handle form submission of the display content editor.

This reads the location of the various blocks from the form, which will have been modified via JavaScript, rearranges them and then saves the display.

File

core/modules/layout/layout.admin.inc, line 918
Administrative functions for Layout module.

Code

function layout_content_form_submit($form, &$form_state) {
  /* @var Layout $layout */
  $layout = &$form_state['layout'];

  // Update the block positions based on the hidden position elements.
  if (!empty($form_state['values']['content']['positions'])) {
    $new_content = array();
    $new_positions = array();

    foreach ($form_state['values']['content']['positions'] as $region_id => $blocks) {
      $new_positions[$region_id] = array();
      if ($blocks) {
        $uuids = array_filter(explode(',', $blocks));
        foreach ($uuids as $uuid) {
          if (isset($layout->content[$uuid])) {
            $new_content[$uuid] = $layout->content[$uuid];
            $new_positions[$region_id][] = $uuid;
          }
        }
      }
    }
    $layout->content = $new_content;
    $layout->positions = $new_positions;
  }

  // Save title settings.
  if (isset($form_state['values']['title_display'])) {
    $layout->settings['title'] = $form_state['values']['title'];
    $layout->settings['title_display'] = $form_state['values']['title_display'];
  }

  // Let layouts save their own settings if needed.
  $layout->formSubmit($form, $form_state);

  // Save the entire layout to configuration.
  $layout->save();

  // Delete the tempstore copy of the layout.
  layout_clear_layout_tempstore($layout->name);

  backdrop_set_message(t('Layout content saved.'));
}