1.20.x layout.context.admin.inc layout_context_add_form_submit($form, &$form_state)

Submit handler for layout_context_add_form().

Saves a context or relationship into the layout.

File

modules/layout/layout.context.admin.inc, line 329
Administrative functions for custom layout contexts.

Code

function layout_context_add_form_submit($form, &$form_state) {
  form_load_include($form_state, 'inc', 'layout', 'layout.admin');
  /* @var Layout $layout */
  $layout = $form_state['layout'];

  if (!isset($form_state['handler'])) {
    return;
  }
  /* @var LayoutAccess $handler */
  $handler = $form_state['handler'];
  $handler->formSubmit($form, $form_state);
  if (!empty($handler->is_new)) {
    $handler->is_new = FALSE;
    $handler->storage = TRUE;
    if ($form_state['clicked_button']['#name'] === 'context_add_button') {
      $layout->setContexts($handler->name, $handler);
    }
    else {
      $uuid = new Uuid();
      $key = $uuid->generate();
      $layout->relationships[$key] = $handler;
    }
  }
  layout_set_layout_tempstore($layout);

  $form_state['ajax_rebuild_form'] = 'layout_settings_form';
  $form_state['ajax_rebuild_args'] = array($layout);
  $form_state['ajax_update'] = array('context_wrapper');
  $form_state['redirect'] = 'admin/structure/layouts/manage/' . $layout->name . '/configure';
}