mirror of
https://github.com/jbcr/core.git
synced 2026-04-27 10:45:54 +02:00
make NotBlank error messages translatable in LoginForm
This commit is contained in:
+12
-4
@@ -12,14 +12,20 @@ namespace Bolt\Form;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class LoginType extends AbstractType
|
||||
{
|
||||
public $authenticationUtils;
|
||||
/** @var AuthenticationUtils */
|
||||
private $authenticationUtils;
|
||||
|
||||
public function __construct(AuthenticationUtils $authenticationUtils)
|
||||
/** @var TranslatorInterface */
|
||||
private $translator;
|
||||
|
||||
public function __construct(AuthenticationUtils $authenticationUtils, TranslatorInterface $translator)
|
||||
{
|
||||
$this->authenticationUtils = $authenticationUtils;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
@@ -34,24 +40,26 @@ namespace Bolt\Form;
|
||||
'label' => 'label.username_or_email',
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'Please enter your username or email',
|
||||
'message' => $this->translator->trans('form.empty_username_email'),
|
||||
]),
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => 'placeholder.username_or_email',
|
||||
],
|
||||
'data' => $last_username,
|
||||
'required' => false
|
||||
])
|
||||
->add('password', PasswordType::class, [
|
||||
'label' => 'label.password',
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'Please enter your password',
|
||||
'message' => $this->translator->trans('form.empty_password'),
|
||||
]),
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => 'placeholder.password',
|
||||
],
|
||||
'required' => false
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2373,5 +2373,17 @@
|
||||
<target>Select …</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="2SSLP1K" name="form.empty_username_email">
|
||||
<segment>
|
||||
<source>form.empty_username_email</source>
|
||||
<target>Please enter your username or email</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="5Qf_RiO" name="form.empty_password">
|
||||
<segment>
|
||||
<source>form.empty_password</source>
|
||||
<target>Please enter your password</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
||||
Reference in New Issue
Block a user