You are here

public function PaymentStatusForm::form in Payment 8.2

Same name in this branch
  1. 8.2 src/Entity/PaymentStatus/PaymentStatusForm.php \Drupal\payment\Entity\PaymentStatus\PaymentStatusForm::form()
  2. 8.2 src/Entity/Payment/PaymentStatusForm.php \Drupal\payment\Entity\Payment\PaymentStatusForm::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/Entity/PaymentStatus/PaymentStatusForm.php, line 75

Class

PaymentStatusForm
Provides the payment status add/edit form.

Namespace

Drupal\payment\Entity\PaymentStatus

Code

public function form(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\payment\Entity\PaymentStatusInterface $payment_status */
  $payment_status = $this
    ->getEntity();
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#default_value' => $payment_status
      ->label(),
    '#maxlength' => 255,
    '#required' => TRUE,
  );
  $form['id'] = array(
    '#default_value' => $payment_status
      ->id(),
    '#disabled' => !$payment_status
      ->isNew(),
    '#machine_name' => array(
      'source' => array(
        'label',
      ),
      'exists' => array(
        $this,
        'PaymentStatusIdExists',
      ),
    ),
    '#maxlength' => 255,
    '#type' => 'machine_name',
    '#required' => TRUE,
  );
  $form['parent_id'] = $this
    ->getParentPaymentStatusSelector($form_state)
    ->buildSelectorForm([], $form_state);
  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => $this
      ->t('Description'),
    '#default_value' => $payment_status
      ->getDescription(),
    '#maxlength' => 255,
  );
  return parent::form($form, $form_state);
}