Skip to content
Snippets Groups Projects

Resolve #3455222 "Automated drupal 11"

1 unresolved thread
4 files
+ 11
7
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -12,6 +12,8 @@ use Drupal\Core\Plugin\CachedDiscoveryClearerInterface;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field_validation\ConfigurableFieldValidationRuleInterface;
use Drupal\field_validation\FieldValidationRuleSetInterface;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -225,11 +227,13 @@ abstract class FieldValidationRuleFormBase extends FormBase {
];
$test_roles = $this->fieldValidationRule->getApplicableRoles();
$roles = Role::loadMultiple();
$names = array_map(fn(RoleInterface $role) => $role->label(), $roles);
$form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Apply to this roles'),
'#default_value' => $test_roles,
'#options' => array_map('\Drupal\Component\Utility\Html::escape', user_role_names()),
'#options' => array_map('\Drupal\Component\Utility\Html::escape', $names),
'#description' => $this->t('If you select no roles, the rule will be applicable for all users.'),
];
Loading