function redhen_note_form_submit in RedHen CRM 7
Submit handler for redhen_note_form().
File
- modules/
redhen_note/ includes/ redhen_note.forms.inc, line 52 - Form definition and handling for redhen notes.
Code
function redhen_note_form_submit($form, &$form_state) {
$redhen_note = $form_state['redhen_note'];
if (isset($form_state['entity'])) {
$entity = $form_state['entity'];
}
else {
$wrapper = entity_metadata_wrapper('redhen_note', $redhen_note);
$entity = $wrapper->entity
->value();
}
list($entity_id, , ) = entity_extract_ids($redhen_note->entity_type, $entity);
$redhen_note->entity_id = $entity_id;
field_attach_submit('redhen_note', $redhen_note, $form, $form_state);
if ($redhen_note
->save()) {
$entity_type = $redhen_note->entity_type;
drupal_set_message(t('The note has been saved.'));
$uri = entity_uri($entity_type, $entity);
$form_state['redirect'] = $uri['path'] . "/notes";
}
else {
drupal_set_message(t('There has been an issue saving this note. Please contact the site administrator.'));
watchdog('redhen_note', 'Issue saving note %note_id.', array(
'%note_id' => $redhen_note->note_id,
), WATCHDOG_NOTICE);
}
}