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

Ignoring extract errors #85

Open
lsv opened this issue Mar 1, 2018 · 1 comment
Open

Ignoring extract errors #85

lsv opened this issue Mar 1, 2018 · 1 comment

Comments

@lsv
Copy link

lsv commented Mar 1, 2018

In a choicetype form element, Im using a Enumtype for choices

$builder->add('gender', ChoiceType::class, [
            'label' => 'Gender',
            'choices' => GenderEnumType::getChoices(),
            'required' => $options['fullprofile'],
            'validation_groups' => $validationGroups,
        ]);

The extractor says this

[ERROR] /home/lsv/Projects/findfesten.dk/src/Form/ProfileType.php                                                      
         Line: 65                                                                                                       
         Message: Form choice is not an array       

Which is indeed 'choices' => GenderEnumType::getChoices(), I know that this is a an array

protected static $choices = [
        self::UNKNOWN => 'Not provided',
        self::MALE => 'Male',
        self::FEMALE => 'Female',
    ];

public static function getChoices(): array
{
    return \array_flip(static::$choices);
}

Is there a way to ignore this line? with a annotations or something? - I dont want to ignore the whole form, but just this single line - Something like this

$builder->add('gender', ChoiceType::class, [
            'label' => 'Gender',
            /** @IgnoreTransNextLine */
            'choices' => GenderEnumType::getChoices(),
            'required' => $options['fullprofile'],
            'validation_groups' => $validationGroups,
        ]);
@Nyholm
Copy link
Member

Nyholm commented Mar 23, 2018

Thank you for this issue. Im not sure if this is documented or not. But this should work:

$builder->add('gender', ChoiceType::class, [
            'label' => 'Gender',
            /** @Ignore */
            'choices' => GenderEnumType::getChoices(),
            'required' => $options['fullprofile'],
            'validation_groups' => $validationGroups,
        ]);

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

No branches or pull requests

2 participants