class CurrencyAmountElement in Currency 8.3
Provides a form to test the currency_amount element.
Hierarchy
- class \Drupal\currency_test\CurrencyAmountElement implements FormInterface
Expanded class hierarchy of CurrencyAmountElement
1 string reference to 'CurrencyAmountElement'
- currency_test.routing.yml in modules/
currency_test/ currency_test.routing.yml - modules/currency_test/currency_test.routing.yml
File
- modules/
currency_test/ src/ CurrencyAmountElement.php, line 11
Namespace
Drupal\currency_testView source
class CurrencyAmountElement implements FormInterface {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'currency_test_currency_amount_element';
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
\Drupal::state()
->set('currency_test_currency_amount_element', $values['container']['amount']);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CurrencyAmountElement:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
CurrencyAmountElement:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
CurrencyAmountElement:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
CurrencyAmountElement:: |
public | function |
Form validation handler. Overrides FormInterface:: |