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

Issue with "has-error" class on <form> element #263

Closed
althaus opened this issue Jun 26, 2014 · 3 comments
Closed

Issue with "has-error" class on <form> element #263

althaus opened this issue Jun 26, 2014 · 3 comments

Comments

@althaus
Copy link
Contributor

althaus commented Jun 26, 2014

Hey,

I stumbled upon an issue with the form (error) rendering. This code snippet in the form_start Twig block leads to bad form error rendering:

{% block form_start %}
    {% spaceless %}
        ...
        {% if form.vars.errors|length > 0 %}
            {% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' has-error')|trim }) %}
        {% endif %}

https://github.com/braincrafted/bootstrap-bundle/blob/develop/Resources/views/Form/bootstrap.html.twig#L739

The result is that all children are rendered as they have errors themselves, because the CSS from Bootstrap is simply

.has-error .help-block, ... {
    color: #a94442;
}

I don't know if there's a reason behind adding that class to the form root as Bootstrap hasn't anything about that in their docs. I fixed this by overriding the Twig block and renaming the error class there.

Cheers
Matthias

@sandello-alkr
Copy link
Contributor

#214 (comment)

@althaus
Copy link
Contributor Author

althaus commented Jun 27, 2014

@sandello-alkr Cheers for the tip.

I'm still convinced that the current (out-of-the-box) implementation isn't a good one. Adding has-error to the <form> just renders all form fields as erroneous. Don't think that's something you'd like to have when you're using global errors.

My situation:
I've got some complex custom constraints targeting a whole class. Validations are added at global level. Mixing those with regular property based ones, leads to an unusable user feedback... as everything is just red. :[

@tlfbrito
Copy link
Contributor

tlfbrito commented Jul 7, 2014

Any progress on this?

florianeckerstorfer pushed a commit that referenced this issue Jul 30, 2014
Fixed conflict with BS error class (fixes #263)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants