public function HeartbeatStreamForm::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 EntityForm::buildForm
File
- src/
Form/ HeartbeatStreamForm.php, line 74
Class
- HeartbeatStreamForm
- Form controller for Heartbeat stream edit forms.
Namespace
Drupal\heartbeat\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\heartbeat\Entity\HeartbeatStream */
$entity =& $this->entity;
$form = parent::buildForm($form, $form_state);
if (!$this->entity
->isNew()) {
$form['new_revision'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Create new revision'),
'#default_value' => FALSE,
'#weight' => 10,
);
}
$form['types'] = array(
//TODO this isn't setting defaults
'#type' => 'checkboxes',
'#options' => $this->heartbeatTypeService
->getTypes(),
'#title' => $this
->t('Please select all the Heartbeat Types you wish to include in this stream'),
'#default' => array(
0,
1,
),
'#value' => array(
0,
1,
),
);
$form['path'] = array(
'#type' => 'textfield',
'#description' => 'The relative url path for this Heartbeat Stream',
'#default' => $entity
->getPath(),
'#value' => $entity
->getPath()
->getValue()[0]['value'],
);
$form['weight'] = array(
'#type' => 'number',
'#description' => 'The weight of the stream',
'#default' => $entity
->getWeight(),
'#value' => $entity
->getWeight()
->getValue()[0]['value'],
);
return $form;
}