Skip to content

Help message not displayed for Checkbox in 3 themes (bootstrap3, foundation5) #35006

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

Closed
emmanuelballery opened this issue Dec 17, 2019 · 0 comments

Comments

@emmanuelballery
Copy link

Symfony version(s) affected: >4.1.0

Description

bootstrap_3_layout.html.twig, bootstrap_3_horizontal_layout.html.twig and foundation_5_layout.html.twig do not support help message for checkbox field ;

Originally reported in #29135 but closed due to lack of feedback.

How to reproduce

Standalone Controller: src/Controller/DefaultController.php

<?php declare(strict_types=1);

namespace App\Controller;

use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends AbstractController
{
    /**
     * @Route(methods={"GET"})
     */
    public function index(): Response
    {
        $form = $this
            ->createFormBuilder()
            ->add('isChecked', CheckboxType::class, ['help' => 'foo'])
            ->getForm();

        return $this->render('foo.html.twig', [
            'form' => $form->createView(),
        ]);
    }
}

Template: templates/foo.html.twig

{#
form_div_layout.html.twig
form_table_layout.html.twig
bootstrap_3_layout.html.twig
bootstrap_3_horizontal_layout.html.twig
bootstrap_4_layout.html.twig
bootstrap_4_horizontal_layout.html.twig
foundation_5_layout.html.twig
#}

<h1>bootstrap_3_layout.html.twig</h1>
{% form_theme form 'bootstrap_3_layout.html.twig' %}
{{ form(form) }}

image
image

Possible Solution

form_help is not called in bootstrap_3_layout.html.twig or bootstrap_3_horizontal_layout.html.twig or foundation_5_layout.html.twig in the block checkbox_row.

See bootstrap_3_layout.html.twig here:

{% block checkbox_row -%}
    <div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
        {{- form_widget(form) -}}
        {{- form_errors(form) -}}
    </div>
{%- endblock checkbox_row %}

You can spot the difference with the same block in bootstrap_4_horizontal_layout.html.twig:

{% block checkbox_row -%}
    <div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
        <div class="{{ block('form_label_class') }}"></div>{#--#}
        <div class="{{ block('form_group_class') }}">
            {{- form_widget(form) -}}
            {{- form_help(form) -}}
        </div>{#--#}
    </div>
{%- endblock checkbox_row %}

It was fixed for bootstrap 4 in 68a9a07.

@emmanuelballery emmanuelballery changed the title Help message not displayed for Checkbox in 3 themes (bootstrap3, Help message not displayed for Checkbox in 3 themes (bootstrap3, foundation5) Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants