Closed avoine closed 10 years ago
i guess a less naive way to add form-control is via attrs.html:
{% if "class" in attrs.keys %}
{% for name, value in attrs.iteritems %} {{ name }}{% if name == "class" %}="form-control {{ value }}"{% if value != True %}="{{ value }}"{% endif %}{% endif %}{% endfor %}
{% else %}
{% for name, value in attrs.iteritems %} {{ name }}{% if value != True %}="{{ value }}"{% endif %}{% endfor %} class="form-control"
{% endif %}
Hi, I think if you want to use bootstrap3 you can use the following package: https://github.com/grundleborg/django-floppyforms-bootstrap3
I've tried to make floppyform to work with bootstrap3. After minor modifications to the templates, I realized that every input widget needed the "form-control" class.
So I naively patch the Input.get_context method in widgets.py to add this simple code:
Then, I needed something to apply does changes to the modelForms. But because of how Django handled modelForm it was not easy. Fortunately, I found that code to me help out:
https://github.com/pydanny/django-admin2/blob/develop/djadmin2/forms.py
But I still need to do something like:
Class MyForm(forms.ModelForm): ....
MyForm = floppify_form(MyForm)
So I was wondering if there is something that could be done to make bootstrap3 simpler. (Note: the modelForms problem might be better in an other issue...)