class CurrencySignElement in Currency 8.3
Provides a form to test the currency_sign element.
Hierarchy
- class \Drupal\currency_test\CurrencySignElement implements FormInterface
Expanded class hierarchy of CurrencySignElement
1 string reference to 'CurrencySignElement'
- currency_test.routing.yml in modules/
currency_test/ currency_test.routing.yml - modules/currency_test/currency_test.routing.yml
File
- modules/
currency_test/ src/ CurrencySignElement.php, line 11
Namespace
Drupal\currency_testView source
class CurrencySignElement implements FormInterface {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'currency_test_currency_sign_element';
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@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_sign_element', $values['container']['sign']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CurrencySignElement:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
CurrencySignElement:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
CurrencySignElement:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
CurrencySignElement:: |
public | function |
Form validation handler. Overrides FormInterface:: |