You are here

public function FormElementTest::buildForm in Entity Browser 8.2

Same name and namespace in other branches
  1. 8 tests/modules/entity_browser_test/src/Form/FormElementTest.php \Drupal\entity_browser_test\Form\FormElementTest::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 FormInterface::buildForm

File

tests/modules/entity_browser_test/src/Form/FormElementTest.php, line 25

Class

FormElementTest
Provides a user login form.

Namespace

Drupal\entity_browser_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#cache']['max-age'] = 0;
  $form['fancy_entity_browser'] = [
    '#type' => 'entity_browser',
    '#entity_browser' => 'test_entity_browser_iframe',
  ];
  if ($default = \Drupal::request()
    ->get('default_entity')) {
    $form['fancy_entity_browser']['#default_value'] = [
      EntityBrowserElement::processEntityId($default),
    ];
  }
  if ($selection_mode = \Drupal::request()
    ->get('selection_mode')) {
    $form['fancy_entity_browser']['#selection_mode'] = $selection_mode;
  }
  $form['main_submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}