You are here

public function TextFieldForm::form in Apache Solr Config Generator 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/TextFieldForm.php, line 23
Contains Drupal\apachesolr_confgen\Form\TextFieldForm.

Class

TextFieldForm
Class TextFieldForm.

Namespace

Drupal\apachesolr_confgen\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $solr_text_field = $this->entity;
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $solr_text_field
      ->label(),
    '#description' => $this
      ->t("Label for the TextField."),
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $solr_text_field
      ->id(),
    '#machine_name' => array(
      'exists' => '\\Drupal\\apachesolr_confgen\\Entity\\TextField::load',
    ),
    '#disabled' => !$solr_text_field
      ->isNew(),
  );

  /* You will need additional form elements for your custom properties. */
  return $form;
}