public function YamlFormRating::form in YAML Form 8
Gets the actual configuration form array to be built.
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 An associative array contain the element's configuration form without any default values..
Overrides Range::form
File
- src/
Plugin/ YamlFormElement/ YamlFormRating.php, line 94
Class
- YamlFormRating
- Provides a 'rating' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['number']['#title'] = $this
->t('Rating settings');
$form['number']['star_size'] = [
'#type' => 'select',
'#title' => $this
->t('Star size'),
'#options' => [
'small' => $this
->t('Small (@size)', [
'@size' => '16px',
]),
'medium' => $this
->t('Medium (@size)', [
'@size' => '24px',
]),
'large' => $this
->t('Large (@size)', [
'@size' => '32px',
]),
],
'#required' => TRUE,
];
$form['number']['reset'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show reset button'),
'#description' => $this
->t('If checked, a reset button will be placed before the rating element.'),
'#return_value' => TRUE,
];
return $form;
}