function civicrm_entity_form_submit in CiviCRM Entity 7
Same name and namespace in other branches
- 7.2 civicrm_entity.default_form.inc \civicrm_entity_form_submit()
Form API submit callback for the entity form.
1 string reference to 'civicrm_entity_form_submit'
File
- ./
civicrm_entity.module, line 567 - Implement CiviCRM entities as a Drupal Entity.
Code
function civicrm_entity_form_submit(&$form, &$form_state) {
$entity_type = $form_state['entity_type'];
//@todo - what is the correct way to do this - taken from bangpound but then I had to do casting
$entity = entity_ui_controller($entity_type)
->entityFormSubmitBuildEntity($form, $form_state);
$entity = new CivicrmEntity((array) $entity, $entity_type);
// Add in created and changed times.
if ($entity->is_new = isset($entity->is_new) ? $entity->is_new : 0) {
$entity->created = time();
}
$entity->changed = time();
$entity
->save();
$t_args = array(
'%label' => entity_label($entity_type, $entity),
);
drupal_set_message(t('Drupal fields on %label have been updated.', $t_args));
}