You are here

public function PanelizerEntityDefault::hook_field_attach_submit in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::hook_field_attach_submit()

File

plugins/entity/PanelizerEntityDefault.class.php, line 2002
Base class for the Panelizer Entity plugin.

Class

PanelizerEntityDefault
Base class for the Panelizer Entity plugin.

Code

public function hook_field_attach_submit($entity, &$form, &$form_state) {
  list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
  if (!empty($form_state['panelizer has choice'])) {
    foreach ($this->plugin['view modes'] as $view_mode => $view_mode_info) {
      if (isset($form_state['values']['panelizer'][$view_mode]['name'])) {
        $entity->panelizer[$view_mode] = $this
          ->get_default_panelizer_object($bundle . '.' . $view_mode, $form_state['values']['panelizer'][$view_mode]['name']);
        if (!empty($entity->panelizer[$view_mode])) {
          $entity->panelizer[$view_mode]->did = NULL;

          // Ensure original values are maintained, if they exist.
          if (isset($form['panelizer'][$view_mode]['name'])) {
            $entity->panelizer[$view_mode]->entity_id = $form['panelizer'][$view_mode]['name']['#entity_id'];
            $entity->panelizer[$view_mode]->revision_id = $form['panelizer'][$view_mode]['name']['#revision_id'];
          }
        }
      }
    }
  }
}