Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a FormType without an entity, the extractor doesn't work on constraints #374

Open
mneute opened this issue Jul 5, 2016 · 4 comments

Comments

@mneute
Copy link

mneute commented Jul 5, 2016

Q A
Bundle version 1.2.3
Symfony version 2.8.8
PHP version 5.4

I'm using a simple FormType that isn't supposed to populate an entity, I just want the user to answer a simple Yes/No question.

class MyFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('myQuestion', 'choice', [
                // ...
                'constraints' => [
                    new IsFalse(['message' => 'validator.messages.invalid_answer'])
                ]
            ]);
    }
}

Symfony translates the error message if I add it manually to the translation file, but the command php app/console translation:extract doesn't detect it, so it always removes it from my translation file.

It would be nice if this kind of constraint message could be detected by the extractor.

Edit
Precised the exact versions

@Nyholm
Copy link
Collaborator

Nyholm commented Jul 7, 2016

Yes, it is supposed to populate that entity. Im not sure if version 1.2.0 did though... Do you have the same issue with the latest version of the bundle?

You could get around the problem by using the --keep parameter.

@mneute
Copy link
Author

mneute commented Jul 12, 2016

I edited my answer to add the exact versions.

You're right, I could use the --keep parameter as a workaround, but the extractor should still detect those messages.

@grigoryosifov
Copy link

grigoryosifov commented Dec 1, 2016

I confirm the same issue with version 1.3.1 and the latest master.

Q A
Bundle version 1.3.1/master
Symfony version 3.1.7
PHP version 7.0.9

It's quite annoying to keep all the non used translations.

@DocDams
Copy link

DocDams commented May 31, 2017

Q A
Bundle version master
Symfony version 3.2.9
PHP version 7.0.18

Same issue with message in a NotBlank constraint.
But NotNull has been correctly retrieved by extractor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants