public function BeanInlineEntityFormController::entityFormSubmit in Bean (for Drupal 7) 7
Overrides EntityInlineEntityFormController::entityFormSubmit().
Overrides EntityInlineEntityFormController::entityFormSubmit
File
- includes/
bean.inline_entity_form.inc, line 204 - Defines the inline entity form controller for Nodes.
Class
- BeanInlineEntityFormController
- @file Defines the inline entity form controller for Nodes.
Code
public function entityFormSubmit(&$entity_form, &$form_state) {
if (isset($form_state['redirect'])) {
$before = $form_state['redirect'];
}
// The parents array tells us exactly what part of the form was
// submitted. We're going to mock out a subsection of $form_state to
// pass to bean_form_submit instead of the whole thing.
$parents = $entity_form['#parents'];
$ief_form_state['bean'] = $entity_form['#entity'];
$ief_form_state['values'] = $form_state['values'];
foreach ($parents as $parent) {
$ief_form_state['values'] = $ief_form_state['values'][$parent];
}
// Get lables to set temporary label and title.
$display_labels = $this
->labels();
// Set label since it will be auto generated based on the parent entity.
if (empty($ief_form_state['bean']->label) && $this->settings['parent_sync_label']) {
$ief_form_state['values']['label'] = $display_labels['singular'];
}
// Set title since it will be auto generated based on the parent entity.
if (empty($ief_form_state['bean']->title) && $this->settings['parent_sync_title']) {
$ief_form_state['values']['title'] = $display_labels['singular'];
}
// Load bean.pages.inc so we can call bean_form_submit
module_load_include('inc', 'bean', 'includes/bean.pages');
// Saves initial bean via bean_form_submit().
bean_form_submit($entity_form, $ief_form_state);
// Undo the redirect set by bean_form_submit().
if (isset($form_state['redirect'])) {
if (isset($before)) {
$form_state['redirect'] = $before;
}
else {
unset($form_state['redirect']);
}
}
}