public function SearchEmbeddedForm::buildForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php \Drupal\search_embedded_form\Form\SearchEmbeddedForm::buildForm()
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
- core/
modules/ search/ tests/ modules/ search_embedded_form/ src/ Form/ SearchEmbeddedForm.php, line 28 - Contains \Drupal\search_embedded_form\Form\SearchEmbeddedForm.
Class
- SearchEmbeddedForm
- Form controller for search_embedded_form form.
Namespace
Drupal\search_embedded_form\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$count = \Drupal::state()
->get('search_embedded_form.submit_count');
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Your name'),
'#maxlength' => 255,
'#default_value' => '',
'#required' => TRUE,
'#description' => $this
->t('Times form has been submitted: %count', array(
'%count' => $count,
)),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Send away'),
);
return $form;
}