braincrafted / bootstrap-bundle

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

Whitespace in choice_widget_option #453

Open AntoineLemaire opened 7 years ago

AntoineLemaire commented 7 years ago

My form :

$builder->add('grade', \Symfony\Component\Form\Extension\Core\Type\ChoiceType::class, [
    'choices'  => ['1' => 1, '2' => 2, '3' => 3, '4' => 5, '5' => 6],
    'required' => false,
    'label'    => 'app.label',
]);

My twig :

{{ form_start(formTest) }}
    {{ form_widget(formTest.grade) }}
{{ form_end(formTest) }}

Result :

capture du 2016-10-24 18-37-43

Instead of

capture du 2016-10-24 18-39-20

But I don't understand because it's work with that: https://github.com/Yoopies/bootstrap-bundle/commit/987e91da336e8515ab00f632ff44acfa5bcf470d, even if choice_widget_options block is under {% spaceless %}

nifr commented 7 years ago

{% spaceless %} does not do anything inside html tags. Have a look at the documentation.

Use the spaceless tag to remove whitespace between HTML tags, not whitespace within HTML tags or whitespace in plain text:

You can easily control/adjust whitespace to your liking using css ( white-space ). There's a nice interactive widget to play around with over at MDN Link

{{- and -}} can be used additionally to strip any whitespace inside tags.

AntoineLemaire commented 7 years ago

Right, I had not enouth read the doc about {%spaceless% } But this change has been introduce with https://github.com/braincrafted/bootstrap-bundle/commit/14906821a9d146e724293217ccb59d0fc59b0628

Sould we bring back the whitespace logic as before instead of add useless spaces which could break our javascript? In case of JS problem, CSS is unfortunately not an option

https://jsfiddle.net/saw9fhfo/