You are here

function ProfileTypeFormController::form in Profile 2 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/ProfileTypeFormController.php, line 25
Contains \Drupal\profile\ProfileTypeFormController.

Class

ProfileTypeFormController
Form controller for profile type forms.

Namespace

Drupal\profile

Code

function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $type = $this->entity;
  if ($this->operation == 'add') {
    $form['#title'] = String::checkPlain($this
      ->t('Add profile type'));
  }
  else {
    $form['#title'] = $this
      ->t('Edit %label profile type', array(
      '%label' => $type
        ->label(),
    ));
  }
  $form['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#default_value' => $type
      ->label(),
    '#description' => t('The human-readable name of this profile type.'),
    '#required' => TRUE,
    '#size' => 30,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $type
      ->id(),
    '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    '#machine_name' => array(
      'exists' => array(
        $this,
        'exists',
      ),
    ),
  );
  $form['registration'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include in user registration form'),
    '#default_value' => $type->registration,
  );
  $form['multiple'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow multiple profiles'),
    '#default_value' => $type->multiple,
  );
  return $form;
}