You are here

public function ContentImport::buildForm in Content Import 8

Same name and namespace in other branches
  1. 8.9 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::buildForm()
  2. 8.3 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::buildForm()
  3. 8.4 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::buildForm()

Content Import Form.

Overrides ConfigFormBase::buildForm

File

src/Form/ContentImport.php, line 47
Contains \Drupal\contentimport\Form\ContentImport.

Class

ContentImport
Configure Content Import settings for this site.

Namespace

Drupal\contentimport\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $ContentTypes = ContentImportController::getAllContentTypes();
  $selected = 0;
  $form['contentimport_contenttype'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select Content Type'),
    '#options' => $ContentTypes,
    '#default_value' => $selected,
  ];
  $form['file_upload'] = [
    '#type' => 'managed_file',
    '#title' => t('Import CSV File'),
    '#size' => 40,
    '#description' => t('Select the CSV file to be imported. '),
    '#required' => FALSE,
    '#autoupload' => TRUE,
    '#upload_validators' => array(
      'file_validate_extensions' => array(
        'csv',
      ),
    ),
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Import'),
    '#button_type' => 'primary',
  ];
  return parent::buildForm($form, $form_state);
}