forked from GNUsocial/gnu-social
[UTIL][FORM] Create a utility class that defines common form fields, such as passwords
This commit is contained in:
parent
dfc97d2607
commit
855d427442
@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Util;
|
||||
|
||||
use function App\Core\I18n\_m;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
abstract class FormFields
|
||||
{
|
||||
public static function password()
|
||||
public static function repeated_password()
|
||||
{
|
||||
return ['password', RepeatedType::class,
|
||||
['type' => PasswordType::class,
|
||||
@ -27,4 +30,17 @@ abstract class FormFields
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public static function password()
|
||||
{
|
||||
['password', PasswordType::class, [
|
||||
'label' => _m('Password'),
|
||||
'mapped' => false,
|
||||
'constraints' => [
|
||||
new NotBlank(['message' => _m('Please enter a password')]),
|
||||
new Length(['min' => Common::config('password', 'min_length'), 'minMessage' => _m(['Your password should be at least # characters'], ['count' => Common::config('password', 'min_length')]),
|
||||
'max' => Common::config('password', 'max_length'), 'maxMessage' => _m(['Your password should be at most # characters'], ['count' => Common::config('password', 'max_length')]), ]),
|
||||
], ],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user