public function RoleLoginPageSettings::buildForm in Multiple role login pages 8
Parameters
array $form:
FormStateInterface $form_state:
Return value
string
Overrides FormInterface::buildForm
File
- src/
Form/ RoleLoginPageSettings.php, line 44 - Contains \Drupal\role_login_page\Form\RoleLoginPageSettings.
Class
- RoleLoginPageSettings
- Add login page form.
Namespace
Drupal\role_login_page\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$roles_arr = Role::loadMultiple();
foreach ($roles_arr as $role => $rolesObj) {
$roles[$role] = $rolesObj
->get('label');
}
$form['login_page_menu'] = [
'#type' => 'fieldset',
'#title' => t('Add login page'),
'#collapsible' => FALSE,
];
$form['login_page_menu']['loginmenu_url'] = [
'#type' => 'textfield',
'#title' => 'Login page url',
'#required' => TRUE,
'#description' => t('URL should exclude the basepath, i.e, "http://example.com". Add the path that should be used after base path, i.e, "user or admin/newconfig"'),
];
$form['login_page_menu']['username_label'] = [
'#type' => 'textfield',
'#title' => 'Username label',
];
$form['login_page_menu']['password_label'] = [
'#type' => 'textfield',
'#title' => 'Password label',
];
$form['login_page_menu']['submit_text'] = [
'#type' => 'textfield',
'#title' => 'Submit button text',
];
$form['login_page_menu']['page_title'] = [
'#type' => 'textfield',
'#title' => 'Page title',
];
$form['login_page_menu']['redirect_path'] = [
'#type' => 'textfield',
'#title' => 'Redirect path',
'#description' => t('Path should exclude the basepath, i.e, "http://example.com". Add the path that should be used after base path, i.e, "user or admin/newconfig"'),
];
$form['login_page_menu']['roles'] = [
'#type' => 'select',
'#title' => 'Select the user roles allowed to login through this page : ',
'#options' => $roles,
'#multiple' => TRUE,
'#required' => TRUE,
];
$form['login_page_menu']['parent_class'] = [
'#type' => 'textfield',
'#title' => 'Form parent class',
'#description' => t('This class will be added to the form element.'),
];
$form['login_page_menu']['role_mismatch_error_text'] = [
'#type' => 'textarea',
'#title' => 'Role mismatch error text',
];
$form['login_page_menu']['invalid_credentials_error_text'] = [
'#type' => 'textarea',
'#title' => 'Invalid credentials error text',
];
$form['login_page_menu']['submit'] = [
'#type' => 'submit',
'#value' => 'Create login page',
];
return $form;
}