arteria / cmsplugin-contact-plus

With cmsplugin-contact-plus building custom forms for your django-cms project is a breeze. Now it's so easy to build the forms with exactly the fields you want in the order you want - with a minimal effort.
https://github.com/arteria/cmsplugin-contact-plus
BSD 3-Clause "New" or "Revised" License
30 stars 33 forks source link

Ability to customise form class used from the settings #37

Closed browniebroke closed 1 year ago

browniebroke commented 8 years ago

Needed that to be able to style my "contact us" form with Bootstrap 3 using a crispy form helper.

settings.py

CMSPLUGIN_CONTACT_FORMCLASS = 'myapp.forms.MyContactUsForm'

forms.py python 3

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from cmsplugin_contact_plus.forms import ContactFormPlus

class MyContactUsForm(ContactFormPlus):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_tag = False

contact.html

{% load crispy_forms_tags %}
{% if form %}
  <form {% if form.is_multipart %}enctype="multipart/form-data"{% endif %} method="POST" action="" class="form">
    {% crispy form %}
    <div class="text-right">
      <input type="submit" class="btn btn-primary" name="contact_plus_form_{{ contact.id }}" {% if contact.submit %} value="{{ contact.submit }}"{% endif %} />
    </div>
  </form>
{% else %}
  {{ contact.thanks|safe }}
{% endif %}
philippeowagner commented 8 years ago

Thanks @browniebroke for your PR. Will check that...

racitup commented 6 years ago

You should also consider making this enhancement compatible with form class modules that automatically give client-side form validation, for example django-angular