You are here

public function SortAddForm::form in Entity Share 8.3

Same name and namespace in other branches
  1. 8 modules/entity_share_server/src/Form/SortAddForm.php \Drupal\entity_share_server\Form\SortAddForm::form()
  2. 8.2 modules/entity_share_server/src/Form/SortAddForm.php \Drupal\entity_share_server\Form\SortAddForm::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

modules/entity_share_server/src/Form/SortAddForm.php, line 19

Class

SortAddForm
Form to add a sort on a channel.

Namespace

Drupal\entity_share_server\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $form['path'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Path'),
    '#description' => $this
      ->t('Enter the machine name of the field / property you want to sort on. You can reference field / property of a referenced entity. Example: uid.name for the name of the author.'),
    '#required' => TRUE,
  ];
  $form['sort_id'] = [
    '#type' => 'machine_name',
    '#title' => $this
      ->t('ID'),
    '#machine_name' => [
      'source' => [
        'path',
      ],
      'exists' => [
        $this,
        'sortExists',
      ],
    ],
  ];
  $form['direction'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Direction'),
    '#options' => $this
      ->getDirectionOptions(),
    '#default_value' => 'ASC',
    '#required' => TRUE,
  ];
  $form['weight'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Weight'),
    '#default_value' => 0,
    '#required' => TRUE,
  ];
  return $form;
}