public function EditQuantity::viewsForm in Commerce Ajax Add to Cart 8
Form constructor for the views form.
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 EditQuantity::viewsForm
File
- modules/
dc_ajax_add_cart_views/ src/ Plugin/ views/ field/ EditQuantity.php, line 18
Class
- EditQuantity
- Defines a form element for editing the order item quantity.
Namespace
Drupal\dc_ajax_add_cart_views\Plugin\views\fieldCode
public function viewsForm(array &$form, FormStateInterface $form_state) {
parent::viewsForm($form, $form_state);
$wrapper_id = $this->view->storage
->id() . '-cart-ajax-wrapper';
$form['#attached']['library'][] = 'core/jquery.form';
$form['#attached']['library'][] = 'core/drupal.ajax';
$form['#prefix'] = "<div id='{$wrapper_id}'>";
$form['#suffix'] = '</div>';
$form['actions']['submit']['#attributes']['class'][] = 'use-ajax-submit';
$form['actions']['submit']['#ajax'] = [
'wrapper' => $wrapper_id,
];
}