public function OrderWorkflowForm::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 ConfigFormBase::submitForm
File
- uc_order/
src/ Form/ OrderWorkflowForm.php, line 126
Class
- OrderWorkflowForm
- Displays the order workflow form for order state and status customization.
Namespace
Drupal\uc_order\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('uc_order.settings');
foreach ($form_state
->getValue('order_states') as $key => $value) {
$config
->set("default_state.{$key}", $value['default']);
}
$config
->save();
foreach ($form_state
->getValue('order_statuses') as $id => $value) {
$status = OrderStatus::load($id);
if (!empty($value['remove'])) {
$status
->delete();
$this
->messenger()
->addMessage($this
->t('Order status %status removed.', [
'%status' => $status
->getName(),
]));
}
else {
$status
->setName($value['name']);
$status
->setWeight((int) $value['weight']);
// The state cannot be changed if the status is locked.
if (!$status
->isLocked()) {
$status
->setState($value['state']);
}
$status
->save();
}
}
parent::submitForm($form, $form_state);
}