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

label_attr arguments ignored in bootstrap_3_layout #15046

Closed
jonathanbull opened this issue Jun 20, 2015 · 4 comments
Closed

label_attr arguments ignored in bootstrap_3_layout #15046

jonathanbull opened this issue Jun 20, 2015 · 4 comments
Labels

Comments

@jonathanbull
Copy link

I'm using the bootstrap_3_layout. If I use form_label arguments, they are ignored:

{{ form_label(form.foo, 'Foo', {'label_attr': {'class': 'bar'}}) }}

<label>
   *default humanized label*
</label>

This does not happen with form_div_layout:

{{ form_label(form.foo, 'Foo', {'label_attr': {'class': 'bar'}}) }}

<label class="bar">
   Foo
</label>
@jonathanbull jonathanbull changed the title label_attr doesn't work with bootstrap_3_layout label_attr properties ignored in bootstrap_3_layout Jun 20, 2015
@jonathanbull jonathanbull changed the title label_attr properties ignored in bootstrap_3_layout label_attr arguments ignored in bootstrap_3_layout Jun 20, 2015
@Tobion Tobion added the Form label Jun 20, 2015
@xabbuh
Copy link
Member

xabbuh commented Jun 28, 2015

@jonathanbull Unfortunately, I was not able to reproduce your issue. Does this happen for all form types? Could you provide a fork of the Symfony Standard Edition that reproduces this?

@jonathanbull
Copy link
Author

@xabbuh Sorry, I've just realised that this only affects checkboxes under the bootstrap layout:

{{ form_widget(form.fooCheckbox) }}
{{ form_label(form.fooCheckbox, 'Foo') }}

Could you please give it another go? If you're still unable to reproduce it, I'd be happy to provide that fork.

@xabbuh
Copy link
Member

xabbuh commented Jun 28, 2015

@jonathanbull The checkbox type is a bit special when using the Bootstrap theme as the label will already be handled by the widget. So form_label() will render nothing and you will have to pass label options to form_widget():

{{ form_widget(form.foo, 'Foo', {'label_attr': {'class': 'bar'}}) }}

@xabbuh xabbuh closed this as completed Jun 28, 2015
@xabbuh
Copy link
Member

xabbuh commented Jun 28, 2015

By the way, this will soon be reflected in the documentation on symfony.com when symfony/symfony-docs#5460 is merged.

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