You are here

function RegistrationViewsHandlerStateEdit::views_form_submit in Entity Registration 8

Same name and namespace in other branches
  1. 8.2 modules/registration_views/registration_views.module \RegistrationViewsHandlerStateEdit::views_form_submit()
  2. 7.2 modules/registration_views/registration_views.module \RegistrationViewsHandlerStateEdit::views_form_submit()
  3. 7 modules/registration_views/registration_views.module \RegistrationViewsHandlerStateEdit::views_form_submit()

Form submit method.

File

modules/registration_views/registration_views.module, line 349
Entity Registration Views integration

Class

RegistrationViewsHandlerStateEdit
A Views' field handler for editing the registration state.

Code

function views_form_submit($form, &$form_state) {

  // Determine which nodes we need to update.
  $updates = array();
  foreach ($this->view->result as $row_index => $row) {
    $value = $form_state['values'][$this->options['id']][$row_index];
    if ($row->{$this->aliases['state']} != $value) {
      $updates[$row->{$this->aliases['registration_id']}] = $value;
    }
  }
  $registrations = registration_load_multiple(array_keys($updates));
  foreach ($registrations as $registration_id => $registration) {
    $registration->state = $updates[$registration_id];
    registration_save($registration);
  }
  drupal_set_message(t('Updated @num registration states.', array(
    '@num' => count($updates),
  )));
}