[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:
Eliseu Amaro 2021-08-16 21:43:27 +01:00 committed by Hugo Sales
parent ab10cd4121
commit 87d7318de5
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 12 additions and 1 deletions

View File

@ -0,0 +1,5 @@
<!-- https://github.com/primer/octicons -->
<!-- MIT License -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32">
<path fill-rule="evenodd" d="M8 16A8 8 0 108 0a8 8 0 000 16zm3.78-9.72a.75.75 0 00-1.06-1.06L6.75 9.19 5.28 7.72a.75.75 0 00-1.06 1.06l2 2a.75.75 0 001.06 0l4.5-4.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 334 B

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);