Adds a form editor to the structure board of django CMS.
Project description
djangocms-form-builder supports rendering of styled forms. The objective is to tightly integrate forms in the website design. djangocms-form-builder allows as many forms as you wish on one page. All forms are xhr-based. To this end, djangocms-form-builder extends the django CMS plugin model allowing a form plugin to receive xhr post requests.
There are two different ways to manage forms with djangocms-form-builder:
Building a form with django CMS’ powerful structure board. This is fast an easy. It integrates smoothly with other design elements, especially the grid elements allowing to design simple responsive forms.
Form actions can be configured by form. Built in actions include saving the results in the database for later evaluation and mailing submitted forms to the site admins. Other form actions can be registered.
Works with django CMS v4 and djangocms-alias to manage your forms centrally. Djangocms-alias becomes your form editor and forms can be placed on pages by referring to them with their alias.
Registering an application-specific form with djangocms-form-builder. If you already have forms you may register them with djangocms-form-builder and allow editors to use them in the form plugin. If you only have simpler design requirements, djangocms-form-builder allows you to use fieldsets as with admin forms.
Key features
Supports Bootstrap 5.
Open architecture to support other css frameworks.
Integrates with django-crispy-forms
Integrates with djangocms-frontend
Feedback
This project is in a early stage. All feedback is welcome! Please mail me at fsbraun(at)gmx.de
Also, all contributions are welcome.
Contributing
This is a an open-source project. We’ll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.
We’re grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.
Installation
For a manual install:
run pip install djangocms-form-builder, or
run pip install git+https://github.com/fsbraun/djangocms-form-builder@master#egg=djangocms-form-builder
add djangocms_form_builder to your INSTALLED_APPS. (If you are using both djangocms-frontend and djangocms-form-builder, add it after djangocms-frontend
run python manage.py migrate
Usage
Creating forms using django CMS’ structure board
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).
Add form fields by adding child classes to the form plugin. Child classes can be form fields but also any other CMS Plugin. CMS Plugins may, e.g., be used to add custom formatting or additional help texts to a form.
Form fields
Currently the following form fields are supported:
CharField, EmailField, URLField
DecimalField, IntegerField
Textarea
DateField, DateTimeField, TimeField
SelectField
BooleanField
A Form plugin must not be used within another Form plugin.
Actions
Upon submission of a valid form actions can be performed. A project can register as many actions as it likes:
from djangocms_form_builder import actions @actions.register class MyAction(actions.FormAction): verbose_name = _("Everything included action") def execute(self, form, request): ... # This method is run upon successful submission of the form
Using (existing) Django forms with djangocms-form-builder
The Form plugin also provides access to Django forms if they are registered with djangocms-form-builder:
from djangocms_form_builder import register_with_form_builder @register_with_form_builder class MyGreatForm(forms.Form): ...
Alternatively you can also register at any other place in the code by running register_with_form_builder(AnotherGreatForm).
By default the class name is translated to a human readable form (MyGreatForm -> "My Great Form"). Additional information may be added using Meta classes:
@register_with_form_builder class MyGreatForm(forms.Form): class Meta: verbose_name = _("My great form") # can be localized redirect = "https://somewhere.org" # string or object with get_absolute_url() method floating_labels = True # switch on floating labels field_sep = "mb-3" # separator used between fields (depends on css framework)
The verbose name will be shown in a Select field of the Form plugin.
Upon form submission a save() method of the form (if it has one). After executing the save() method the user is redirected to the url given in the redirect attribute.
Actions are not available for Django forms. Any actions to be performed upon submission should reside in its save() method.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file djangocms_form_builder-0.1.1.tar.gz
.
File metadata
- Download URL: djangocms_form_builder-0.1.1.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6d103f516258dacc0516c45c936bb1a40dbe1d4c3b7c42a201c5e196399d67 |
|
MD5 | ac6d928f328e6a7986c0d5e4eeaf8fdd |
|
BLAKE2b-256 | 226547ad52f56a4ac142dd6dbf072f4d7753c2dcd27edbbb5481a5a22835876d |
File details
Details for the file djangocms_form_builder-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: djangocms_form_builder-0.1.1-py3-none-any.whl
- Upload date:
- Size: 76.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ed47d672dda13c9012e35dc8d0b946e49edd967a24325936d4042134d98a0c7 |
|
MD5 | 284b67d816ffeca51e9088ed2209bcea |
|
BLAKE2b-256 | f2a4b2750982f240910172fffb77a930be81453508f00af089da71923eb20721 |