braincrafted / bootstrap-bundle

BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.
http://bootstrap.braincrafted.com
MIT License
399 stars 184 forks source link

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

Open Bubelbub opened 8 years ago

Bubelbub commented 8 years ago

Hey guys,

I'm risking the use of the new Symfony 3.1 with this not 100% compatible BraincraftedBootstrapBundle :+1: Normally everything works really really great! :tada:

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 :+1: Thanks in Advance for anything :+1:

Arunijus commented 8 years ago

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

derpue commented 8 years ago

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 commented 7 years ago

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.