You are here

public function AttributeAddForm::submitForm in Ubercart 8.4

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

uc_attribute/src/Form/AttributeAddForm.php, line 15

Class

AttributeAddForm
Defines the attribute add form.

Namespace

Drupal\uc_attribute\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Remove Form API elements from $form_state.
  $form_state
    ->cleanValues();
  $aid = $this->database
    ->insert('uc_attributes')
    ->fields($form_state
    ->getValues())
    ->execute();
  if ($form_state
    ->getValue('display') == 0) {

    // No options needed/allowed for Textfield display type.
    $form_state
      ->setRedirect('uc_attribute.overview', [
      'aid' => $aid,
    ]);
  }
  else {

    // All other display types we redirect to add options.
    $form_state
      ->setRedirect('uc_attribute.options', [
      'aid' => $aid,
    ]);
  }
}