You are here

public function AddToCart::buildForm in Basic cart 8

Same name and namespace in other branches
  1. 8.0 src/Form/AddToCart.php \Drupal\basic_cart\Form\AddToCart::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/AddToCart.php, line 22

Class

AddToCart

Namespace

Drupal\basic_cart\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $id = NULL, $entitytype = NULL, $langcode = NULL) {
  $config = Utility::cartSettings();
  $form['id'] = array(
    '#type' => 'hidden',
    '#required' => TRUE,
    '#value' => $id,
  );
  $form['entitytype'] = array(
    '#type' => 'hidden',
    '#required' => TRUE,
    '#value' => $entitytype,
  );
  $form['langcode'] = array(
    '#type' => 'hidden',
    '#required' => TRUE,
    '#value' => $langcode,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t($config
      ->get('add_to_cart_button')),
  );
  return $form;
}