public function CurrencySignElement::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/ CurrencySignElement.php, line 23
Class
- CurrencySignElement
- Provides a form to test the currency_sign element.
Namespace
Drupal\currency_testCode
public function buildForm(array $form, FormStateInterface $form_state, $currency_code = NULL, $currency_sign = NULL) {
// Nest the element to make sure that works.
$form['container'] = array(
'#tree' => TRUE,
);
$form['container']['sign'] = array(
'#currency_code' => $currency_code ? $currency_code : FALSE,
'#default_value' => $currency_sign,
'#type' => 'currency_sign',
'#title' => t('Foo sign'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}