public function FriendSearchForm::buildForm in Heartbeat 8
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
- src/
Form/ FriendSearchForm.php, line 50
Class
- FriendSearchForm
- Class FriendSearchForm.
Namespace
Drupal\heartbeat\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['search'] = [
'#type' => 'entity_autocomplete',
'#entity_type' => 'user',
'#target_type' => 'user',
'#autocomplete_route_name' => 'entity-autocomplete/user/',
'#title' => $this
->t('Friends'),
'#description' => $this
->t('Search for friends by name'),
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Search'),
'#ajax' => [
'callback' => '::friendSearchAjaxSubmit',
'progress' => array(
'type' => 'throbber',
'message' => t('Finding friends'),
),
],
];
return $form;
}