You are here

public function GeysirParagraphForm::form in Geysir 8

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

1 call to GeysirParagraphForm::form()
GeysirModalParagraphForm::form in src/Form/GeysirModalParagraphForm.php
Gets the actual form array to be built.
1 method overrides GeysirParagraphForm::form()
GeysirModalParagraphForm::form in src/Form/GeysirModalParagraphForm.php
Gets the actual form array to be built.

File

src/Form/GeysirParagraphForm.php, line 17

Class

GeysirParagraphForm
Functionality to edit a paragraph.

Namespace

Drupal\geysir\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $route_match = $this
    ->getRouteMatch();
  $parent_entity_type = $route_match
    ->getParameter('parent_entity_type');
  $parent_entity_revision = $route_match
    ->getParameter('parent_entity_revision');
  $field_name = $route_match
    ->getParameter('field');
  $delta = $route_match
    ->getParameter('delta');

  // Get the parent revision if available, otherwise the parent.
  $parent_entity_revision = $this
    ->getParentRevisionOrParent($parent_entity_type, $parent_entity_revision);
  $field = $parent_entity_revision
    ->get($field_name);
  $field_definition = $field
    ->getFieldDefinition();
  $field_label = $field_definition
    ->getLabel();
  $form['#title'] = $this
    ->t('Edit @delta of @field of %label', [
    '@delta' => $delta,
    '@field' => $field_label,
    '%label' => $parent_entity_revision
      ->label(),
  ]);
  return $form;
}