﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29189	BoundField: extra css classes	James Pic	nobody	"Currently, [https://github.com/django/django/blob/d368784bacc7e58b426f29937ee842aa14d439ad/django/forms/forms.py#L218 Form._html_output()] calls [https://github.com/django/django/blob/d368784bacc7e58b426f29937ee842aa14d439ad/django/forms/boundfield.py#L166 BoundField.css_classes()] to get the list of classes to apply on the field container, such as error_css_class or required_css_class.

My objective is something like : 
{{{
form['myfield'].extra_css_classes = 'hide'
}}}

(Setting the class in JS too, but this causes a flash of course)

Could we perhaps allow adding extra css classes to BoundField ?

Currently I have this little hack which works but isn't doing anything that's supposed to be supported so please bare with me, it's just here to serve as an example and attempt to illustrate what I would like to get rid of in my own code:

{{{
class BoundField(forms.BoundField):
    """"""BoundField override for facond Form.""""""

    def css_classes(self):
        """"""Allow setting extra_css_classes.""""""
        return super(BoundField, self).css_classes(
            getattr(self, 'extra_css_classes', ''))

class Form(forms.Form):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():  
            # not sure what it breaks to instanciate BoundFields here
            # rather than in __getitem__
            self._bound_fields_cache[name] = BoundField(self, field, name)
}}}

Thanks in advance for your feedback, I can submit a patch if you want."	New feature	new	Forms	2.0	Normal			James Pic	Unreviewed	0	0	0	0	0	0
