-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
No Bootstrap markup is rendered for label set as false #18504
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
No Bootstrap markup is rendered for label set as false #18504
Conversation
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form) -}} | ||
{{- form_errors(form) -}} | ||
{% set displayMarkup = form.children|length == 0 or form.vars.label is not same as(false) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not change the behavior when form.children|length == 0
imo.
This is not a bug, other templates show the label, and may be part of the work in progress feature in #17609.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a bug displaying a form-group
inside a form-group
. The label i still shown - the markup is not rendered when the label is set to false.
I cannot see how this will be solved in your pr. It looks like another feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I misread the condition, IIUC you force the label (even false
) to be printed when there is no child.
So I guess this should be right.
LGTM. @jongotlin Can you add some tests to ensure that we don't break this again in the future? |
Ref #18850. |
@jongotlin Did you check your PR respect the second sample of #18850 (comment)? ->add('test', TextType::class, [
'mapped' => false,
'label' => false,
'attr' => [
'placeholder' => 'My label goes here',
]
]) |
Also:
|
This does not see my issue. I download your patch and tried with this form config: public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('domain', null, [
'label' => 'ssl_certificate.form.domain',
'translation_domain' => 'front',
])
->add('subdomains', CollectionType::class, [
'label' => 'ssl_certificate.form.subdomains',
'translation_domain' => 'front',
'type' => TextType::class,
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'options' => [
'label' => false,
'text_suffix' => '',
'attr' => [
'class' => 'subdomain-domain',
],
],
])
;
} Result: This solve not this issue: #18850 (comment) |
Or the issue is not really related and in this case #18850 should be re-opened. |
Please see this alternative: #19247 |
Thanks @soullivaneuh. I didn't think of the CollectionType-example you provided. I'll look into how it can be solved. |
Not sure how to solve @soullivaneuh s issue. I guess also the prototype is affected. Anyone having an idea where to start? |
@jongotlin I check vertical form, I have no issue about this at all. The only solution I found is to correct the column classes in #19247. |
Closing in favor of #19247 |
When using horizontal Bootstrap forms and setting

'label' => false
for a custom form type theform_row
renders an ugly markupThis pr fixes that and make the form look like this
