You are here

public function AddFolderForm::buildForm in Taxonomy File Tree 8

Same name and namespace in other branches
  1. 3.x src/Form/AddFolderForm.php \Drupal\tft\Form\AddFolderForm::buildForm()

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

File

src/Form/AddFolderForm.php, line 25

Class

AddFolderForm
Add a term form.

Namespace

Drupal\tft\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t("Name"),
    '#required' => TRUE,
    '#weight' => -10,
  ];
  $parent = !empty($_GET['parent']) ? (int) $_GET['parent'] : 0;
  $form['parent'] = [
    '#type' => 'hidden',
    '#value' => $parent,
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Add'),
    '#button_type' => 'primary',
  ];
  $cancel_uri = str_replace('%23', '#', $_GET['destination']);
  $form['actions']['cancel'] = [
    '#type' => 'link',
    '#title' => $this
      ->t("cancel"),
    '#url' => Url::fromUri('internal:' . $cancel_uri),
  ];
  return $form;
}