You are here

public function ElevateZoomPlusForm::edit_form_submit in ElevateZoom Plus 7

Handle the submission of the edit form.

At this point, submission is successful. Our only responsibility is to copy anything out of values onto the item that we are able to edit.

If the keys all match up to the schema, this method will not need to be overridden.

Overrides ctools_export_ui::edit_form_submit

File

modules/ui/src/Form/ElevateZoomPlusForm.php, line 530

Class

ElevateZoomPlusForm
Extends base form for elevatezoomplus instance configuration form.

Namespace

Drupal\elevatezoomplus_ui\Form

Code

public function edit_form_submit(&$form, &$form_state) {
  parent::edit_form_submit($form, $form_state);

  // Optimize optimize options to free up some bytes.
  $entity = $form_state['item'];
  $default = $entity
    ->id() == 'default';
  if (!$default) {
    $defaults = ElevateZoomPlus::defaultSettings();
    $settings = $form_state['values']['options']['settings'];

    // Cast the values.
    $this
      ->typecastOptionset($settings);
    $optimized_values = array_diff_assoc($settings, $defaults);
    if (isset($optimized_values['respond'])) {
      foreach ($optimized_values['respond'] as &$respond) {
        $respond = array_diff_assoc($respond, $defaults);
      }
    }
    $entity
      ->setSettings($optimized_values);
  }
}