public function AddToCartWithQuantity::buildForm in Basic cart 8
Same name and namespace in other branches
- 8.0 src/Form/AddToCartWithQuantity.php \Drupal\basic_cart\Form\AddToCartWithQuantity::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ AddToCartWithQuantity.php, line 22
Class
Namespace
Drupal\basic_cart\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $id = NULL, $entitytype = NULL, $langcode = NULL) {
$config = Utility::cartSettings();
$form['addtocart_container'] = array(
'#type' => 'fieldset',
'#title' => t($config
->get('add_to_cart_button')),
);
$form['addtocart_container']['id'] = array(
'#type' => 'hidden',
'#required' => TRUE,
'#value' => $id,
);
$form['addtocart_container']['entitytype'] = array(
'#type' => 'hidden',
'#required' => TRUE,
'#value' => $entitytype,
);
$form['addtocart_container']['langcode'] = array(
'#type' => 'hidden',
'#required' => TRUE,
'#value' => $langcode,
);
$form['addtocart_container']['quantity'] = array(
'#type' => 'textfield',
'#title' => t($config
->get('quantity_label')),
'#required' => TRUE,
'#size' => 1,
'#maxlength' => 6,
);
$form['addtocart_container']['submit'] = array(
'#type' => 'submit',
'#value' => t($config
->get('add_to_cart_button')),
);
return $form;
}