You are here

public function ImportForm::buildForm in Taxonomy Import 2.x

Same name and namespace in other branches
  1. 8 src/Form/ImportForm.php \Drupal\taxonomy_import\Form\ImportForm::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/ImportForm.php, line 25

Class

ImportForm
Contribute form.

Namespace

Drupal\taxonomy_import\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['field_vocabulary_name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Vocabulary name'),
    '#required' => TRUE,
    '#maxlength_js' => TRUE,
    '#maxlength' => 30,
    '#description' => $this
      ->t('Not more than 30 characters please!'),
  ];
  $form['taxonomy_file'] = [
    '#type' => 'managed_file',
    '#title' => $this
      ->t('Import file'),
    '#required' => TRUE,
    '#upload_validators' => [
      'file_validate_extensions' => [
        'csv xml',
      ],
      'file_validate_size' => [
        25600000,
      ],
    ],
    '#upload_location' => 'public://taxonomy_files/',
    '#description' => $this
      ->t('Upload a file to Import taxonomy!'),
  ];
  $form['actions']['#type'] = 'actions';
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Import'),
    '#button_type' => 'primary',
  ];
  return $form;
}