function entityform_edit_form_submit in Entityform 7
Same name and namespace in other branches
- 7.2 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 455 - Entityform editing UI.
Code
function entityform_edit_form_submit(&$form, &$form_state) {
$entityform = entity_ui_controller('entityform')
->entityFormSubmitBuildEntity($form, $form_state);
$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);
// Add in created and changed times.
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
->save();
if ($form_state['entityform_form_mode'] == 'submit') {
if (empty($entityform->draft)) {
$redirect_path = $entityform_type
->get_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 submussion 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(t('Your submission has been saved.'));
}
else {
$form_state['redirect'] = entity_ui_controller('entityform')
->draft_path($entityform->type);
drupal_set_message(t('Your draft submission has been saved.'));
}
}
else {
$info = entity_get_info('entityform_type');
$form_state['redirect'] = $info['admin ui']['path'] . "/manage/{$entityform_type->type}/submissions";
drupal_set_message(t('The submission has been saved.'));
}
}