public function ContentImport::buildForm in Content Import 8.9
Same name and namespace in other branches
- 8 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::buildForm()
- 8.3 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::buildForm()
- 8.4 src/Form/ContentImport.php \Drupal\contentimport\Form\ContentImport::buildForm()
Content Import Form.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ ContentImport.php, line 36
Class
- ContentImport
- Configure Content Import settings for this site.
Namespace
Drupal\contentimport\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$contentTypes = ContentImportController::getAllContentTypes();
$form['contentimport_contenttype'] = [
'#type' => 'select',
'#title' => $this
->t('Select Content Type'),
'#options' => $contentTypes,
'#default_value' => $this
->t('Select'),
'#required' => TRUE,
'#description' => $this
->t('Select content type to be import'),
];
$form['contentimport_importtype'] = [
'#type' => 'select',
'#title' => $this
->t('Select Import Type'),
'#options' => [
'Select',
'Create New content',
'Update existing content',
],
'#default_value' => $this
->t('Select'),
'#required' => TRUE,
'#description' => $this
->t('Select import type to create/update node.'),
'#ajax' => [
'event' => 'change',
'callback' => '::contentImportcallback',
'wrapper' => 'content_import_fields_change_wrapper',
'progress' => [
'type' => 'throbber',
'message' => NULL,
],
],
];
$form['file_upload'] = [
'#type' => 'file',
'#title' => $this
->t('Import CSV File'),
'#size' => 40,
'#description' => $this
->t('Select the CSV file to be imported.'),
'#required' => FALSE,
'#autoupload' => TRUE,
'#upload_validators' => [
'file_validate_extensions' => [
'csv',
],
],
];
$form['loglink'] = [
'#type' => 'link',
'#title' => $this
->t('Check Log..'),
'#url' => Url::fromUri('base:sites/default/files/contentimportlog.txt'),
'#description' => $this
->t('Upload CSV file only with delimter ","'),
];
$form['import_ct_markup'] = [
'#suffix' => '<div id="content_import_fields_change_wrapper"></div>',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Import'),
'#button_type' => 'primary',
];
return parent::buildForm($form, $form_state);
}