[CONTROLLER][SECURITY] Added class names. Help labels for each form element. Each form element now has a proper block prefix (the resulting HTML won't simply concatenate the form's name to the element's label).

This commit is contained in:
2021-08-16 21:43:27 +01:00
committed by Hugo Sales
parent ab10cd4121
commit 87d7318de5
2 changed files with 12 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ class Security extends Controller
$form = Form::create([
['nickname', TextType::class, [
'label' => _m('Nickname'),
'help' => _m('Your desired nickname (e.g., j0hnD03)'),
'constraints' => [
new NotBlank(['message' => _m('Please enter a nickname')]),
new Length([
@@ -80,14 +81,19 @@ class Security extends Controller
'max' => Nickname::MAX_LEN,
'maxMessage' => _m(['Your nickname must be at most # characters long'], ['count' => Nickname::MAX_LEN]), ]),
],
'block_name' => 'nickname',
'label_attr' => ['class' => 'section-form-label'],
]],
['email', EmailType::class, [
'label' => _m('Email'),
'help' => _m('Desired email for this account (e.g., john@provider.com)'),
'constraints' => [ new NotBlank(['message' => _m('Please enter an email') ])],
'block_name' => 'email',
'label_attr' => ['class' => 'section-form-label'],
]],
FormFields::repeated_password(),
['register', SubmitType::class, ['label' => _m('Register')]],
]);
], builder_options: ['block_prefix' => 'register']);
$form->handleRequest($request);