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

[3.1] Collections "type" attribute is ignored #440

Open
Bubelbub opened this issue May 30, 2016 · 3 comments
Open

[3.1] Collections "type" attribute is ignored #440

Bubelbub opened this issue May 30, 2016 · 3 comments

Comments

@Bubelbub
Copy link

Hey guys,

I'm risking the use of the new Symfony 3.1 with this not 100% compatible BraincraftedBootstrapBundle 👍
Normally everything works really really great! 🎉

But I have a problem with collections and it seems like that the type is ignored.

Example form RecipeType:

->add('ingredients', BootstrapCollectionType::class, array(
    'type'               => RecipeIngredientType::class,
    'allow_add'          => true,
    'allow_delete'       => true,
    'by_reference'       => false,
    'add_button_text'    => 'Add ingredient',
    'delete_button_text' => 'Delete ingredient',
    'options'            => array('attr' => array('style' => 'inline')),
    'attr' => array('help_text' => 'ingredient.sort'),
))

And then I have this type RecipeIngredientType:

parent::buildForm($builder, $options);
$builder
    ->add('alternatives', BootstrapCollectionType::class, array(
        'type'               => RecipeIngredientAlternativeType::class,
        'allow_add'          => true,
        'allow_delete'       => true,
        'by_reference'       => false,
        'prototype_name'     => 'inlinep',
        'add_button_text'    => 'Add alternative',
        'delete_button_text' => 'Delete alternative',
        'sub_widget_col'     => 9,
        'button_col'         => 3,
        'options'            => array('attr' => array('style' => 'inline'),)
    ))
;

The error message:

An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class AppBundle\Entity\RecipeIngredient could not be converted to string") in vendor\braincrafted\bootstrap-bundle\Braincrafted\Bundle\BootstrapBundle\Resources\views\Form\bootstrap.html.twig at line 52.

My idea:

If I check the line 15 (not 52) I see this:

{% block form_widget_simple %}

And the system shows the same error message all the time. With "type" attribute and without. - Always the same error.
The system is using this simple field - but it is a collection...

So maybe you can give me more ideas to fix it by myself or maybe you can help by fixing this 👍
Thanks in Advance for anything 👍

@Arunijus
Copy link

I have the same issue after migrating to Symfony 3.1 . Any fixes?

@derpue
Copy link
Contributor

derpue commented Jul 21, 2016

Try with entry_type instead of type.
entry_type was introduced with 2.8 to replace type.

Also options should be replaced by entry_options

Here you can find all the important changes:
https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md

@TomSchillemans
Copy link

TomSchillemans commented Nov 2, 2016

I also get deprication warnings even if I use entry_type.The BootstrapCollectionType still uses it too I believe. This needs to be fixed too. Correct me if I am wrong, but I think if it isn't, you would need to specify the type everytime after symfony 3.0. Even for text types as that is defined as default in the BootstrapCollectionType.

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

4 participants