public function OptionAddForm::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/ OptionAddForm.php, line 29
Class
- OptionAddForm
- Defines the attribute option add form.
Namespace
Drupal\uc_attribute\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Remove Form API elements from $form_state.
$form_state
->cleanValues();
$oid = \Drupal::database()
->insert('uc_attribute_options')
->fields($form_state
->getValues())
->execute();
$aid = $form_state
->getValue('aid');
$option_name = $form_state
->getValue('name');
$edit_option_link = Link::createFromRoute($this
->t('Edit option'), 'uc_attribute.option_edit', [
'aid' => $aid,
'oid' => $oid,
])
->toString();
$this
->messenger()
->addMessage($this
->t('Created new option %option.', [
'%option' => $option_name,
]));
$this
->logger('uc_attribute')
->notice('Created new option %option.', [
'%option' => $option_name,
'link' => $edit_option_link,
]);
$form_state
->setRedirect('uc_attribute.option_add', [
'aid' => $aid,
]);
}