public function FacetSettingsForm::form in Facets 8
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ FacetSettingsForm.php, line 81
Class
- FacetSettingsForm
- Provides a form for creating and editing facets.
Namespace
Drupal\facets\FormCode
public function form(array $form, FormStateInterface $form_state) {
// If the form is being rebuilt, rebuild the entity with the current form
// values.
if ($form_state
->isRebuilding()) {
$this->entity = $this
->buildEntity($form, $form_state);
}
$form = parent::form($form, $form_state);
// Set the page title according to whether we are creating or editing the
// facet.
if ($this
->getEntity()
->isNew()) {
$form['#title'] = $this
->t('Add facet');
}
else {
$form['#title'] = $this
->t('Facet settings for %label facet', [
'%label' => $this
->getEntity()
->label(),
]);
}
$this
->buildEntityForm($form, $form_state, $this
->getEntity());
$form['#attached']['library'][] = 'facets/drupal.facets.edit-facet';
return $form;
}