You are here

public function ConnectionForm::buildForm in RedHen CRM 8

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

File

modules/redhen_connection/src/Form/ConnectionForm.php, line 17

Class

ConnectionForm
Form controller for Connection edit forms.

Namespace

Drupal\redhen_connection\Form

Code

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

  // If we have a fixed endpoint, we replace the input widget with the
  // rendered field.
  if ($fixed_endpoint = $form_state
    ->get('fixed_endpoint')) {

    /* @var $connection \Drupal\redhen_connection\Entity\Connection */
    $connection = $this
      ->getEntity();

    // @ TODO look into configuration of this display.
    $form[$fixed_endpoint] = $connection->{$fixed_endpoint}
      ->view();
  }
  return $form;
}