public function CurrencyLocaleForm::form in Currency 8.3
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Entity/ CurrencyLocale/ CurrencyLocaleForm.php, line 86
Class
- CurrencyLocaleForm
- Provides a currency_locale add/edit form.
Namespace
Drupal\currency\Entity\CurrencyLocaleCode
public function form(array $form, FormStateInterface $form_state) {
/** @var \Drupal\currency\Entity\CurrencyLocaleInterface $currency_locale */
$currency_locale = $this
->getEntity();
$options = array();
foreach (LanguageManager::getStandardLanguageList() as $language_code => $language_names) {
$options[$language_code] = $language_names[0];
}
natcasesort($options);
$form['language_code'] = array(
'#default_value' => $currency_locale
->getLanguageCode(),
'#empty_value' => '',
'#options' => $options,
'#required' => TRUE,
'#title' => $this
->t('Language'),
'#type' => 'select',
);
$form['country_code'] = array(
'#default_value' => $currency_locale
->getCountryCode(),
'#empty_value' => '',
'#options' => $this->countryManager
->getList(),
'#required' => TRUE,
'#title' => $this
->t('Country'),
'#type' => 'select',
);
$form['formatting'] = array(
'#open' => TRUE,
'#title' => $this
->t('Formatting'),
'#type' => 'details',
);
$form['formatting']['decimal_separator'] = array(
'#default_value' => $currency_locale
->getDecimalSeparator(),
'#maxlength' => 255,
'#required' => TRUE,
'#size' => 3,
'#title' => $this
->t('Decimal separator'),
'#type' => 'textfield',
);
$form['formatting']['grouping_separator'] = array(
'#default_value' => $currency_locale
->getGroupingSeparator(),
'#maxlength' => 255,
'#size' => 3,
'#title' => $this
->t('Group separator'),
'#type' => 'textfield',
);
$form['formatting']['pattern'] = array(
'#default_value' => $currency_locale
->getPattern(),
'#description' => $this
->t('A Unicode <abbr title="Common Locale Data Repository">CLDR</abbr> <a href="http://cldr.unicode.org/translation/number-patterns">currency number pattern</a>.'),
'#maxlength' => 255,
'#title' => $this
->t('Pattern'),
'#type' => 'textfield',
);
return parent::form($form, $form_state, $currency_locale);
}