You are here

public function TaxonomyImporterForm::buildForm in Hierarchical Taxonomy Import 8

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/TaxonomyImporterForm.php, line 60

Class

TaxonomyImporterForm
Class TaxonomyImporterForm.

Namespace

Drupal\hierarchical_taxonomy_importer\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $output = [
    [
      'Honda',
      '',
      '',
    ],
    [
      '',
      'Honda',
      '',
    ],
    [
      '',
      '',
      '100',
    ],
    [
      '',
      '',
      '200',
    ],
    [
      '',
      '',
      '300',
    ],
    [
      '',
      '',
      '400',
    ],
    [
      '',
      '',
      '500',
    ],
    [
      '',
      'Londa',
      '',
    ],
    [
      '',
      '',
      '600',
    ],
    [
      '',
      '',
      '700',
    ],
    [
      '',
      '',
      '800',
    ],
    [
      '',
      '',
      '900',
    ],
  ];

  // $this->hierarchicalTaxonomyImporter->import('new_test', $output);.
  $form['vocabulary'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Vocabularies'),
    '#description' => $this
      ->t('Select a vocabulary to import taxonomies terms from CSV file.'),
    '#options' => $this
      ->getVocabularies(),
    '#required' => TRUE,
    '#size' => 1,
  ];
  $form['csv_file'] = [
    '#type' => 'file',
    '#title' => $this
      ->t('CSV File'),
    '#description' => $this
      ->t('Upload a CSV file with taxonomy information.'),
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}