public function CreateRegistrationPageForm::buildForm in Multiple Registration 3.x
Same name and namespace in other branches
- 8.2 src/Form/CreateRegistrationPageForm.php \Drupal\multiple_registration\Form\CreateRegistrationPageForm::buildForm()
- 8 src/Form/CreateRegistrationPageForm.php \Drupal\multiple_registration\Form\CreateRegistrationPageForm::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 ConfigFormBase::buildForm
File
- src/
Form/ CreateRegistrationPageForm.php, line 103
Class
- CreateRegistrationPageForm
- Class CreateRegistrationPageForm.
Namespace
Drupal\multiple_registration\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $rid = NULL) {
if (!isset($rid)) {
return FALSE;
}
$roles = user_role_names();
if (!isset($roles[$rid])) {
return FALSE;
}
$form['rid'] = [
'#type' => 'value',
'#value' => $rid,
];
$config = $this
->config('multiple_registration.create_registration_page_form_config');
$form['multiple_registration_path_' . $rid] = [
'#type' => 'textfield',
'#title' => $this
->t('Registration page path'),
'#description' => $this
->t('Path for registration page.'),
'#default_value' => $config
->get('multiple_registration_path_' . $rid),
];
$form_modes = $this->entityDisplayRepository
->getFormModes('user');
$form_modes_options = [
'default' => $this
->t('Default'),
];
foreach ($form_modes as $key => $form_mode) {
$form_modes_options[$key] = $form_mode['label'];
}
$form['multiple_registration_form_mode_register_' . $rid] = [
'#type' => 'select',
'#title' => $this
->t('Form mode to render the Register form'),
'#default_value' => $config
->get('multiple_registration_form_mode_register_' . $rid) ?: 'register',
'#options' => $form_modes_options,
];
$form['multiple_registration_form_mode_edit_' . $rid] = [
'#type' => 'select',
'#title' => $this
->t('Form mode to render the Edit form'),
'#default_value' => $config
->get('multiple_registration_form_mode_edit_' . $rid) ?: 'default',
'#options' => $form_modes_options,
];
$form['multiple_registration_hidden_' . $rid] = [
'#type' => 'checkbox',
'#title' => $this
->t('Hide registration form tab'),
'#description' => $this
->t('Indicates whether form will be accessible only by url.'),
'#default_value' => $config
->get('multiple_registration_hidden_' . $rid),
];
$form['multiple_registration_url_' . $rid] = [
'#type' => 'value',
'#value' => MultipleRegistrationController::MULTIPLE_REGISTRATION_SIGNUP_PATH_PATTERN . $rid,
];
return parent::buildForm($form, $form_state);
}