function civicrm_entity_profile_field_update in CiviCRM Entity 7.2
Implements hook_field_update().
Parameters
$entity_type:
$entity:
$field:
$instance:
$langcode:
$items:
File
- modules/
civicrm_entity_profile/ civicrm_entity_profile.module, line 304
Code
function civicrm_entity_profile_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
if (($entity_type == 'civicrm_event' || $entity_type == 'civicrm_contribution_page') && $instance['widget']['type'] == 'civicrm_entity_profile_field_default_widget') {
if (!empty($items)) {
if (!empty($entity->id)) {
// need to handle deletion of items that exist but have been removed via multiple fields 'Remove' button
if ($entity_type == 'civicrm_event') {
$module = !empty($instance['settings']['registrant_type']) ? $instance['settings']['registrant_type'] : 'CiviEvent';
}
else {
$module = 'CiviContribute';
}
$uf_join_ids_pre = _civicrm_entity_profile_get_ufjoins($entity_type, $entity->id, $module);
foreach ($uf_join_ids_pre as $uf_join_id) {
$delete = 1;
foreach ($items as $delta => $item) {
if ($item['target_id'] == $uf_join_id) {
$delete = 0;
}
}
if ($delete) {
entity_delete($entity_type, $uf_join_id);
}
}
foreach ($items as $delta => $item) {
_civicrm_entity_profile_process_field_item($entity_type, $entity, $instance, $item, $delta);
unset($items[$delta]);
}
}
}
}
}