public function CheckoutForm::validateForm in Ubercart 8.4
Form validation 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 FormBase::validateForm
File
- uc_cart/
src/ Form/ CheckoutForm.php, line 153
Class
- CheckoutForm
- The checkout form built up from the enabled checkout panes.
Namespace
Drupal\uc_cart\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$order = $form_state
->get('order');
// Update the order "changed" time to prevent timeout on ajax requests.
$order
->setChangedTime($this->dateTime
->getRequestTime());
// Validate/process each cart pane. If one of the process() functions
// returns FALSE, checkout fails.
$form_state
->set('checkout_valid', TRUE);
foreach (Element::children($form_state
->getValue('panes')) as $id) {
$pane = $this->checkoutPaneManager
->createInstance($id);
if ($pane
->process($order, $form, $form_state) === FALSE) {
$form_state
->set('checkout_valid', FALSE);
}
}
// Reload line items and save order.
$order->line_items = $order
->getLineItems();
$order
->save();
}