8000 Forms, collection data transformers · Issue #30622 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Forms, collection data transformers #30622

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

Closed
imsheng opened this issue Mar 21, 2019 · 4 comments
Closed

Forms, collection data transformers #30622

imsheng opened this issue Mar 21, 2019 · 4 comments
Labels

Comments

@imsheng
Copy link
imsheng commented Mar 21, 2019

Symfony version(s) affected: 3.4.23

Description

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('arr', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', [
            'entry_type' => TextType::class,
            'allow_add' => true
        ])
       ;

    $builder->get('arr')
        ->addModelTransformer(new CallbackTransformer(
            function ($value) {
                return json_decode($value, true);
            },
            function ($value) {
                return json_encode($value);
            }
        ));
}

Expected argument of type "array or (\Traversable and \ArrayAccess)", "string" given

Why didn't convert the string to an array?

@xabbuh xabbuh added the Form label Mar 21, 2019
@xabbuh
Copy link
Member
xabbuh commented Mar 21, 2019

I am sorry, but I have to close your issue as we use GitHub issues only to discuss new features and for bug reports. For support, please refer to one of the support channels. Thank you for understanding.

@xabbuh xabbuh closed this as completed Mar 21, 2019
@mayro
Copy link
mayro commented Apr 9, 2019

Hello,
I guess this is a bug on the 3.4 version.
I have the same error when i upgraded to 3.4.
Expected argument of type "array or (\Traversable and \ArrayAccess)", "string" given, I use a ModelTransformer to convert an array to a string, with a collectionType. The same code works with the 3.3 version.
Thank you

@xabbuh
Copy link
Member
xabbuh commented Apr 9, 2019

@mayro Please open a new issue if you think that you found a bug with some instructions on how we can reproduce the issue (best would be a small example application).

@mayro
Copy link
mayro commented Apr 9, 2019

@xabbuh Done #31041 Thank you

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

No branches or pull requests

3 participants
0