public function AjaxAdminForm::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_ajax_admin/
src/ Form/ AjaxAdminForm.php, line 89
Class
- AjaxAdminForm
- Configures Ajax behaviours on the Ubercart checkout page.
Namespace
Drupal\uc_ajax_admin\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $form['#uc_ajax_config'];
foreach ($form_state
->getValue('table') as $index => $entry) {
$key = $entry['key'];
if ($index === '_new') {
if (!empty($key) && !empty($entry['panes'])) {
$config[$key] = $entry['panes'];
}
}
elseif ($entry['remove'] || empty($entry['panes'])) {
unset($config[$key]);
}
else {
$config[$key] = $entry['panes'];
}
}
$this
->configFactory()
->getEditable('uc_cart.settings')
->set('ajax.' . $form['#uc_ajax_target'], $config)
->save();
$this
->messenger()
->addMessage($this
->t('Your changes have been saved.'));
}