public function OrganigramsImportItemsForm::buildForm in Organigrams 8.2
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.
\Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary: The vocabulary to import the terms to.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ OrganigramsImportItemsForm.php, line 77
Class
- OrganigramsImportItemsForm
- Provides the settings form for this module.
Namespace
Drupal\organigrams\FormCode
public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
// Don't do anything if no vocabulary is found.
if (empty($taxonomy_vocabulary)) {
return [
'#markup' => $this
->t('No vocabulary found.'),
];
}
// Add the vocabulary to the form_state.
$form_state
->set([
'taxonomy',
'vocabulary',
], $taxonomy_vocabulary);
// Textarea for the organigram items JSON.
$form['organigrams_items_json'] = [
'#type' => 'textarea',
'#title' => $this
->t('Organigram items JSON'),
'#description' => $this
->t('JSON output of organigrams version 7.x and 8.x is supported.'),
'#required' => TRUE,
'#rows' => 20,
];
// Add a warning message.
$form['warning'] = [
'#markup' => '<strong>' . $this
->t('Warning: this will delete all existing organigram items!') . '</strong>',
];
// Group submit handlers in an actions element with a key of "actions".
$form['actions'] = [
'#type' => 'actions',
];
// Add a submit button that handles the submission of the form.
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}