Skip to content

Commit 9c0dddf

Browse files
committed
Update readme
1 parent 09073bf commit 9c0dddf

File tree

4 files changed

+33
-204
lines changed

4 files changed

+33
-204
lines changed

README.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,35 @@ For a manual install:
6262
Usage
6363
*****
6464

65+
Creating forms using django CMS' structure board
66+
================================================
6567

68+
First create a ``Form`` plugin to add a form. Each form created with help of the structure board needs a unique identifier (formatted as a slug).
69+
70+
Add form fields by adding child classes to the form plugin.
71+
72+
Using (existing) Django forms with djangocms-form-builder
73+
=========================================================
74+
75+
The ``Form`` plugin also provides access to Django forms if they are registered with djangocms-form-builder::
76+
77+
from djangocms_form_builder import register_with_form_builder
78+
79+
@register_with_form_builder
80+
class MyGreatForm(forms.Form):
81+
...
82+
83+
Alternatively you can also register at any other place in the code by running ``register_with_form_builder(AnotherGreatForm)``.
84+
85+
By default the class name is translated to a human readable form (``MyGreatForm`` -> ``"My Great Form"``). Additional information may be added using Meta classes::
86+
87+
@register_with_form_builder
88+
class MyGreatForm(forms.Form):
89+
class Meta:
90+
verbose_name = _("My great form") # can be localized
91+
redirect = "https://somewhere.org" # string or object with get_absolute_url() method
92+
floating_labels = True # switch on floating labels
93+
field_sep = "mp-3" # separator used between fields (depends on css framework)
6694

6795

6896
.. |pypi| image:: https://badge.fury.io/py/djangocms-form-builder.svg

djangocms_form_builder/LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.

djangocms_form_builder/actions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,17 @@ def execute(self, form, request):
107107
)
108108
html_message = render_to_string(self.template, context)
109109
message = strip_tags(html_message)
110+
form_name = form.cleaned_data["form_name"].replace("-", " ").capitalize()
110111
if self.recipients is None:
111112
mail_admins(
112-
self.subject % dict(form_name=""),
113+
self.subject % dict(form_name=form_name),
113114
message,
114115
fail_silently=True,
115116
html_message=html_message,
116117
)
117118
else:
118119
send_mail(
119-
self.subject % dict(form_name=""),
120+
self.subject % dict(form_name=form_name),
120121
message,
121122
self.recipients,
122123
self.from_mail,

djangocms_form_builder/forms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ class Meta:
9292
initial="",
9393
)
9494
form_name = forms.CharField(
95-
label=_("Form name"),
95+
label=_("Form identifier"),
9696
required=False,
9797
initial="",
9898
validators=[
9999
validate_slug,
100100
],
101+
help_text=_("Slug that allows to identify form submissions uniquely.")
101102
)
102103
form_login_required = forms.BooleanField(
103104
label=_("Login required to submit form"),

0 commit comments

Comments
 (0)