public function CurrencyAmountElement::buildForm in Currency 8.3
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/
currency_test/ src/ CurrencyAmountElement.php, line 23
Class
- CurrencyAmountElement
- Provides a form to test the currency_amount element.
Namespace
Drupal\currency_testCode
public function buildForm(array $form, FormStateInterface $form_state, $minimum_amount = NULL, $maximum_amount = NULL, $currency_code = NULL) {
// Nest the element to make sure that works.
$form['container'] = array(
'#tree' => TRUE,
);
$form['container']['amount'] = array(
'#limit_currency_codes' => $currency_code ? array(
$currency_code,
) : array(),
'#type' => 'currency_amount',
'#title' => t('Foo amount'),
'#minimum_amount' => $minimum_amount,
'#maximum_amount' => $maximum_amount,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}