public function EditFolderForm::buildForm in Taxonomy File Tree 8
Same name and namespace in other branches
- 3.x src/Form/EditFolderForm.php \Drupal\tft\Form\EditFolderForm::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/ EditFolderForm.php, line 26
Class
- EditFolderForm
- Edit a term form.
Namespace
Drupal\tft\FormCode
public function buildForm(array $form, FormStateInterface $form_state, TermInterface $taxonomy_term = NULL) {
$name = $taxonomy_term
->getName();
$form['name'] = [
'#type' => 'textfield',
'#title' => t("Name"),
'#required' => TRUE,
'#default_value' => $name,
'#weight' => -10,
];
$form['tid'] = [
'#type' => 'hidden',
'#value' => $taxonomy_term
->id(),
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Save'),
];
$cancel_uri = str_replace('%23', '#', $_GET['destination']);
$form['actions']['cancel'] = [
'#type' => 'link',
'#title' => $this
->t("cancel"),
'#url' => Url::fromUri('internal:' . $cancel_uri),
];
return $form;
}