public function PrepopulateTestForm::buildForm in Prepopulate 8.2
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
- tests/
modules/ prepopulate_test/ src/ Form/ PrepopulateTestForm.php, line 26
Class
- PrepopulateTestForm
- Class PrepopulateTestForm.
Namespace
Drupal\prepopulate_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['checkboxes'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Checkboxes'),
'#options' => [
'black' => $this
->t('Black'),
'blue' => $this
->t('Blue'),
'green' => $this
->t('Green'),
'red' => $this
->t('Red'),
'white' => $this
->t('White'),
'yellow' => $this
->t('Yellow'),
],
];
$form['date'] = [
'#type' => 'date',
'#title' => $this
->t('Date'),
];
$form['datelist'] = [
'#type' => 'datelist',
'#title' => $this
->t('Datelist'),
];
$form['datetime'] = [
'#type' => 'datetime',
'#title' => $this
->t('Datetime'),
];
$form['entity_autocomplete'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#title' => $this
->t('Node Autocomplete'),
];
$form['entity_autocreate'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => $this
->t('Term Autocreate'),
'#autocreate' => [
'bundle' => 'tags',
],
];
$form['email'] = [
'#type' => 'email',
'#title' => $this
->t('Email'),
];
$form['machine_name'] = [
'#type' => 'machine_name',
'#title' => $this
->t('Machine Name'),
'#machine_name' => [
'exists' => '\\Drupal\\views\\Views::getView',
],
'#required' => FALSE,
];
$form['number'] = [
'#type' => 'number',
'#title' => $this
->t('Number'),
];
$form['path'] = [
'#type' => 'path',
'#title' => $this
->t('Path'),
];
$form['radios'] = [
'#type' => 'radios',
'#title' => $this
->t('Radios'),
'#options' => [
'africa' => $this
->t('Africa'),
'antarctica' => $this
->t('Antarctica'),
'asia' => $this
->t('Asia'),
'australia' => $this
->t('Australia'),
'europe' => $this
->t('Europe'),
'north america' => $this
->t('North America'),
'south america' => $this
->t('South America'),
],
];
$form['telephone'] = [
'#type' => 'tel',
'#title' => $this
->t('Telephone'),
];
$form['textarea'] = [
'#type' => 'textarea',
'#title' => $this
->t('Textarea'),
];
$form['textfield'] = [
'#type' => 'textfield',
'#title' => $this
->t('Textfield'),
];
$form['select'] = [
'#type' => 'select',
'#title' => $this
->t('Select'),
'#options' => [
'north' => $this
->t('North'),
'south' => $this
->t('South'),
'east' => $this
->t('East'),
'west' => $this
->t('West'),
],
];
$form['url'] = [
'#type' => 'url',
'#title' => $this
->t('Url'),
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
$form['#cache']['max-age'] = 0;
return $form;
}