public function HeartbeatFeedForm::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/ HeartbeatFeedForm.php, line 81
Class
- HeartbeatFeedForm
- Class HeartbeatFeedForm.
Namespace
Drupal\heartbeat\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
if ($this->stream === null) {
$this->stream = $form_state
->getValue('feedtabs');
}
if ($this->streams === null) {
foreach ($this->streamService
->getAllStreams() as $heartbeatStream) {
$this->streams[$heartbeatStream
->getName()] = t($heartbeatStream
->getName());
}
}
$form['feedtabs'] = [
'#type' => 'radios',
'#title' => $this
->t('Choose a feed'),
// '#description' => $this->t('User selectable feeds'),
'#options' => $this->streams,
'#ajax' => [
'callback' => '::updateFeed',
// 'event' => 'onclick',
'progress' => array(
'type' => 'none',
),
'#default' => $this->streams['Public'],
],
];
// $form['feedsearch'] = [
// '#type' => 'search',
// ];
// $form['submit'] = [
// '#type' => 'submit',
// '#value' => $this->t('Search'),
// ];
$form['#attached']['library'][] = 'heartbeat/heartbeat';
return $form;
}