You are here

public function MergeMultipleForm::buildForm in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Form/MergeMultipleForm.php \Drupal\bibcite_entity\Form\MergeMultipleForm::buildForm()

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 ConfirmFormBase::buildForm

File

modules/bibcite_entity/src/Form/MergeMultipleForm.php, line 120

Class

MergeMultipleForm
Merge multiple bibliographic entities into one.

Namespace

Drupal\bibcite_entity\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $field_name = NULL) {
  $this->entityType = $this->entityTypeManager
    ->getDefinition($entity_type_id);
  $this->entityInfo = $this->tempStore
    ->get($this->currentUser
    ->id());
  $this->fieldName = $field_name;
  $form['entities'] = [
    '#theme' => 'item_list',
    '#items' => $this->entityInfo,
  ];
  $form['target'] = [
    '#type' => 'entity_autocomplete',
    '#title' => $this
      ->t('Select target'),
    '#description' => $this
      ->t('@entity_type_label to be merged into.', [
      '@entity_type_label' => $this->entityType
        ->getLabel(),
    ]),
    '#target_type' => $this->entityType
      ->id(),
    '#required' => TRUE,
  ];
  return parent::buildForm($form, $form_state);
}