You are here

function availability_calendar_field_attach_submit_inc in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.4 availability_calendar.widget.inc \availability_calendar_field_attach_submit_inc()

Called by implementation of hook_field_attach_submit. @link http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...

1 call to availability_calendar_field_attach_submit_inc()
availability_calendar_field_attach_submit in ./availability_calendar.field.inc
Implements hook_field_attach_submit. @link http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...

File

./availability_calendar.widget.inc, line 241

Code

function availability_calendar_field_attach_submit_inc($entity_type, $entity, $form, &$form_state) {
  if (!empty($form_state['availability_calendar_updates'])) {
    foreach ($form_state['availability_calendar_updates'] as $update_info) {

      // A form can contain multiple entities with multiple calendar fields:
      // match the changes with specific fields using the cid_unique value.
      list($field_name, $language_code, $delta, $cid_unique, $changes) = $update_info;
      if (isset($entity->{$field_name}[$language_code][$delta]['cid_unique']) && $entity->{$field_name}[$language_code][$delta]['cid_unique'] === $cid_unique) {

        // If cid is not yet set (i.e. it is a new calendar), cid will get its
        // value from availability_calendar_update_multiple_availability().
        $cid = availability_calendar_update_multiple_availability((int) $cid_unique, $changes);
        if ($cid != $entity->{$field_name}[$language_code][$delta]['cid']) {

          // New calendar: update the field.
          $entity->{$field_name}[$language_code][$delta]['cid'] = $cid;
        }
      }
    }
  }
}