You are here

public function ServiceEndpointForm::form in Services 9.0.x

Same name and namespace in other branches
  1. 8.4 src/Form/ServiceEndpointForm.php \Drupal\services\Form\ServiceEndpointForm::form()

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/ServiceEndpointForm.php, line 44

Class

ServiceEndpointForm
Class \Drupal\services\Form\ServiceEndpointForm.

Namespace

Drupal\services\Form

Code

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

  /* @var $service_endpoint \Drupal\services\Entity\ServiceEndpoint */
  $service_endpoint = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $service_endpoint
      ->label(),
    '#description' => $this
      ->t('Label for the service endpoint.'),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $service_endpoint
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\services\\Entity\\ServiceEndpoint::load',
    ],
    '#disabled' => !$service_endpoint
      ->isNew(),
  ];
  $form['endpoint'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Endpoint'),
    '#maxlength' => 255,
    '#default_value' => $service_endpoint
      ->getEndpoint(),
    '#description' => $this
      ->t('URL endpoint.'),
    '#required' => TRUE,
  ];
  return $form;
}