You are here

public function ProviderForm::form in oEmbed 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/ProviderForm.php, line 23
Contains \Drupal\oembed\Form\ProviderForm.

Class

ProviderForm
Class ProviderForm.

Namespace

Drupal\oembed\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /** @var \Drupal\oembed\ProviderInterface $provider */
  $provider = $this->entity;
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $provider
      ->label(),
    '#description' => $this
      ->t("Label for the Provider."),
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $provider
      ->id(),
    '#machine_name' => array(
      'exists' => '\\Drupal\\oembed\\Entity\\Provider::load',
    ),
    '#disabled' => !$provider
      ->isNew(),
  );
  $form['endpoint'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Endpoint'),
    '#description' => $this
      ->t('The endpoint where oEmbed requests are going to be sent.'),
    '#size' => 32,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#default_value' => $provider
      ->getEndpoint(),
  );
  $form['scheme'] = array(
    '#type' => 'textarea',
    '#title' => $this
      ->t('Schemes'),
    '#description' => $this
      ->t('Newline separated list of schemes like !example', array(
      '!example' => 'http://*.revision3.com/*',
    )),
    '#required' => TRUE,
    '#default_value' => implode(PHP_EOL, $provider
      ->getScheme()),
  );
  return $form;
}