public function FormModeManagerRolesForm::buildFormPerFormMode in Form mode manager 8.2
Build form element per form modes linked by given entity type.
Parameters
array $form: An associative array containing the structure of the form.
array $form_mode: The form mode definition.
string $entity_type_id: The entity type ID of entity.
Return value
$this|false The form Object.
Overrides FormModeManagerFormBase::buildFormPerFormMode
File
- modules/
form_mode_user_roles_assign/ src/ Form/ FormModeManagerRolesForm.php, line 100
Class
- FormModeManagerRolesForm
- Configure Form for Form Mode Manager Role Assign settings.
Namespace
Drupal\form_mode_user_roles_assign\FormCode
public function buildFormPerFormMode(array &$form, array $form_mode, $entity_type_id) {
if ('user' !== $entity_type_id) {
return $this;
}
$form_mode_id = str_replace('.', '_', $form_mode['id']);
$form['user_assign_form_mode_settings'][$entity_type_id]['form_modes'][$form_mode_id] = [
'#type' => 'details',
'#title' => $form_mode['label'],
'#description' => $this
->t('Assign role to (<b>@form_mode_id</b>) form registration.', [
'@form_mode_id' => $form_mode['label'],
]),
'#open' => TRUE,
];
$form['user_assign_form_mode_settings'][$entity_type_id]['form_modes'][$form_mode_id]["{$form_mode_id}_roles"] = [
'#title' => $this
->t('Assign roles'),
'#type' => 'select',
'#empty_value' => [],
'#empty_option' => $this
->t('- Any -'),
'#options' => $this
->getAvailableRoleOptions(),
'#default_value' => $this->settings
->get("form_modes.{$form_mode_id}.assign_roles"),
'#description' => $this
->t("Select the type of theme you want to use. You can choose the themes defined by the drupal configuration (default or admin) or select one with the 'custom' option"),
'#multiple' => TRUE,
];
return $this;
}