public function BulkUserImport::buildForm in Bulk User Registration 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/ BulkUserImport.php, line 68
Class
- BulkUserImport
- Bulk user import form.
Namespace
Drupal\bulk_user_registration\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['file_upload'] = [
'#type' => 'file',
'#title' => $this
->t('Import CSV file'),
'#description' => $this
->t('The CSV file to be imported. Check the CSV sample below if you are not sure about the format.'),
'#autoupload' => TRUE,
'#upload_validators' => [
'file_validate_extensions' => [
'csv',
],
],
];
$form['sample_csv'] = [
'#type' => 'item',
'link' => [
'#type' => 'link',
'#title' => $this
->t('Download sample CSV'),
'#url' => Url::fromRoute('bulk_user_registration.csv_sample'),
],
'#description' => $this
->t('This sample file contains all possible fields and various data samples to get you started.'),
];
$form['default_role'] = [
'#type' => 'select',
'#title' => $this
->t('Default role'),
'#description' => $this
->t('The default role for imported users. When no role data is provided in the CSV, this role will be assigned.'),
'#options' => self::getAllowedRoles(),
'#default_value' => '',
'#required' => TRUE,
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Import'),
'#button_type' => 'primary',
];
return $form;
}