8000 Report a bug in bootstrap_4_horizontal_layout.html.twig · Issue #34008 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Report a bug in bootstrap_4_horizontal_layout.html.twig #34008
Closed
@nimasdj

Description

@nimasdj

I have this in template

    <div class="col">
      {{ form_row(form.privacyRead, {'required': false}) }}
    </div>

and this in controller

    ->add('privacyRead', CheckboxType::class, ['constraints' => [new Assert\IsTrue(['message' => 'privacy.notchecked'])],
     ]) 

But I get the error printed twice as here is the output html:


    <div class="col">
      <div class="form-group row"><div class="col-sm-2"></div><div class="col-sm-10"><div class="form-check">        <input type="checkbox"             id="form_privacyRead" name="form[privacyRead]" class="form-check-input is-invalid" value="1" />
        <label class="form-check-label" for="form_privacyRead">I agree Privacy Policy<span class="invalid-feedback d-block"><span class="d-block">
                    <span class="form-error-icon badge badge-danger text-uppercase">Error</span> <span class="form-error-message">privacy.notchecked</span>
                </span></span></label></div><span class="invalid-feedback d-block"><span class="d-block">
                    <span class="form-error-icon badge badge-danger text-uppercase">Error</span> <span class="form-error-message">privacy.notchecked</span>
                </span></span></div></div>
    </div>

It seems something is wrong in bootstrap_4_horizontal_layout.html.twig template.
In source code:

{% block checkbox_row -%}
    <div class="form-group row">{#--#}
        <div class="{{ block('form_label_class') }}"></div>{#--#}
        <div class="{{ block('form_group_class') }}">
            {{- form_widget(form) -}}
            {{- form_help(form) -}}
            {{- form_errors(form) -}}
        </div>{#--#}
    </div>
{%- endblock checkbox_row %}

{{form_errors(form)}} should be removed. No need to this. It still prints error without it. This one causes in duplicate error printing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0