function entityform_edit_form_submit in Entityform 7.2
Same name and namespace in other branches
- 7 entityform.admin.inc \entityform_edit_form_submit()
Form API submit callback for the entityform form.
@todo remove hard-coded link
1 string reference to 'entityform_edit_form_submit'
- entityform_edit_form in ./
entityform.admin.inc - Form callback: create or edit a entityform.
File
- ./
entityform.admin.inc, line 563 - Entityform editing UI.
Code
function entityform_edit_form_submit(&$form, &$form_state) {
$entityform = entity_ui_controller('entityform')
->entityFormSubmitBuildEntity($form, $form_state);
// Add in created and changed times. This must be added before preview to get time.
if ($entityform->is_new = isset($entityform->is_new) ? $entityform->is_new : 0) {
global $user;
$entityform->created = time();
$entityform->uid = !empty($user->uid) ? $user->uid : 0;
}
$entityform->changed = time();
$entityform->draft = $form_state['clicked_button']['#entityform_draft'];
// Save the entityform and go back to the list of entityforms.
$entityform_type = entityform_type_load($entityform->type);
if (!empty($form_state['clicked_button']['#entityform_change'])) {
$form_state['entityform_preview_entity'] = $entityform;
$form_state['rebuild'] = TRUE;
drupal_set_message(t('Re-enter'));
return;
}
else {
// If this entityform type has preview mode and we are in submit store preview.
if (empty($form_state['clicked_button']['#entityform_after_review']) && !$entityform->draft && !empty($entityform_type->data['preview_page']) && $form_state['entityform_form_mode'] == 'submit') {
$form_state['entityform_preview_entity'] = $entityform;
$form_state['rebuild'] = TRUE;
return;
}
}
$entityform
->save();
if ($form_state['entityform_form_mode'] == 'submit' || !user_access('edit any entityform')) {
if (empty($entityform->draft)) {
$redirect_path = $entityform_type
->get_path_property('redirect_path', $entityform);
if (!empty($redirect_path)) {
$form_state['redirect'] = $redirect_path;
}
else {
global $user;
if (empty($user->uid)) {
// For anonymous users we must store the id of their submission in the session.
drupal_session_start();
$_SESSION['entityform_submission'] = $entityform->entityform_id;
}
$confirm_path = entity_ui_controller('entityform')
->confirm_path($entityform->type, $entityform->entityform_id);
$form_state['redirect'] = array(
$confirm_path[0],
$confirm_path[1],
);
}
drupal_set_message($entityform_type
->get_prop('submit_confirm_msg', $entityform));
}
else {
// Saving a Draft.
$form_state['redirect'] = $entityform_type
->get_path_property('draft_redirect_path', $entityform);
if (empty($form_state['redirect'])) {
// Redirect to standard draft page.
drupal_set_message(t('Your draft submission has been saved.'));
$form_state['redirect'] = entity_ui_controller('entityform')
->draft_path($entityform->type);
}
else {
// Redirecting away from standard draft page. Show text as message.
drupal_set_message($entityform_type
->get_prop('draft_save_text', $entityform));
}
}
}
else {
$info = entity_get_info('entityform_type');
$form_state['redirect'] = $info['admin ui']['path'] . "/manage/{$entityform_type->type}/submissions";
drupal_set_message($entityform_type
->get_prop('submit_confirm_msg', $entityform));
}
}