You are here

function makemeeting_answers_form_submit in Make Meeting Scheduler 7.2

Form submit: store answers

File

./makemeeting.form.inc, line 171

Code

function makemeeting_answers_form_submit($form, $form_state) {
  global $user;
  if (!empty($form_state['values']['answer_edited'])) {
    db_update('makemeeting_answers')
      ->fields([
      'name' => $form_state['values']['name'],
      'value' => serialize($form_state['values']['answers']),
    ])
      ->condition('answer_id', $form_state['values']['answer_edited']->answer_id)
      ->execute();
  }
  else {
    $fields = [];
    foreach ([
      'field_name',
      'entity_type',
      'deleted',
      'entity_id',
      'language',
      'delta',
      'name',
    ] as $field) {
      $fields[$field] = $form_state['values'][$field];
    }
    db_insert('makemeeting_answers')
      ->fields($fields + [
      'value' => serialize($form_state['values']['answers']),
      'uid' => $user->uid,
    ])
      ->execute();
  }

  // Spoof drupal_get_destination()'s cache for ajax calls
  if (current_path() === 'system/ajax') {
    $destination =& drupal_static('drupal_get_destination');
    $destination = $form_state['ajax_destination'];
  }
  _makemeeting_clear_related_entity_cache($form_state['values']['entity_type'], $form_state['values']['entity_id']);
}