You are here

public function PriceTestForm::buildForm in Commerce Core 8.2

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

modules/price/tests/modules/commerce_price_test/src/Form/PriceTestForm.php, line 21

Class

PriceTestForm

Namespace

Drupal\commerce_price_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['amount'] = [
    '#type' => 'commerce_price',
    '#title' => $this
      ->t('Amount'),
    '#default_value' => [
      'number' => '99.99',
      'currency_code' => 'USD',
    ],
    '#required' => TRUE,
    '#available_currencies' => [
      'USD',
      'EUR',
    ],
  ];
  $form['amount_hidden_title'] = [
    '#type' => 'commerce_price',
    '#title' => $this
      ->t('Hidden title amount'),
    '#title_display' => 'invisible',
    '#default_value' => [
      'number' => '99.99',
      'currency_code' => 'USD',
    ],
    '#required' => TRUE,
    '#available_currencies' => [
      'USD',
      'EUR',
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}