Continuation of the deprecated project Divio Aldryn Forms.
Aldryn Forms allows you to build flexible HTML forms for your Aldryn and django CMS projects, and to integrate them directly in your pages.
Forms can be assembled using the form builder, with the familiar simple drag-and-drop interface of the django CMS plugin system.
Submitted data is stored in the Django database, and can be explored and exported using the admin, while forms can be configured to send a confirmation message to users.
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.
Choose a site you want to install the add-on to from the dashboard. Then go to Apps -> Install app
and click Install
next to Forms
app.
Redeploy the site.
Version 2.0 introduced a new model for form data storage called FormSubmission
.
The old FormData
model has been deprecated.
Although the FormData
model's data is still accessible through the admin, all new form data will be stored in the new
FormSubmission
model.
Run pip install djangocms-aldryn-forms
.
Update INSTALLED_APPS
with
INSTALLED_APPS = [ ... 'aldryn_forms', 'aldryn_forms.contrib.email_notifications', 'captcha', ... ]
Also ensure you define an e-mail backend for your app.
You can create forms in the admin interface now. Search for the label Aldryn_Forms
.
Create a CMS page and install the Forms
app there (choose Forms
from the Advanced Settings -> Application
dropdown).
Now redeploy/restart the site again.
The above CMS site has become a forms POST landing page - a place where submission errors get displayed if there are any.
FormPlugin
plugin lets you embed certain forms on a CMS page.Fieldset
groups fields.TextField
renders text input.TextAreaField
renders text input.HiddenField
PhoneField
DateField
DateTimeLocalField
TimeField
NumberField
EmailField
FileField
renders a file upload input.MultipleFilesField
ImageField
same asFileField
but validates that the uploaded file is an image.BooleanField
renders checkbox.SelectField
renders single select input.MultipleSelectField
MultipleCheckboxSelectField
renders multiple checkboxes.CaptchaField
HideContentWhenPostPlugin
Dispatch submitted form by middleware. If the HTTP header HTTP_X_DJANGOCMS_ALDRYN_FORMS
is SubmittedForm
a json response is returned.
Write in settings.py:
MIDDLEWARE = [ ... "aldryn_forms.middleware.handle_post.HandleHttpPost" ]
Activation of repeated saving to the same post.
Write in settings.py:
# Send email after 30 minutes. Remove post_ident after 30 minutes. ALDRYN_FORMS_MULTIPLE_SUBMISSION_DURATION = 30
After this entry, the post_ident
parameter is added to the success url for redirection. For example
/thank-you/?post_ident=HErQ2TunSAU0AhTKrNSVDtSVBoYr9gTvUCUsdpMg6AZVqzExXCK06Tm7XIznf1sw
Activating form submission via javascript fetch
: Add class submit-by-fetch
into element form
.
Example:
<form class="submit-by-fetch"> ... </form>
Use the Form with Ident field
plugin in the administration.
In the run_next
dataset parameter, enter the name of the function to be executed after receiving the response
from javascript fetch
command.
Example:
<form data-run_next="runNext"> ... </form>
Example of runNext
javascript function:
function runNext(form, data) { ... for (const input of document.querySelectorAll('input.aldryn-forms-field-ident')) { input.value = data.post_ident } ... }
The command aldryn_forms_remove_expired_post_idents
deletes the post_ident
values for all records older than the value in ALDRYN_FORMS_MULTIPLE_SUBMISSION_DURATION
.
The command aldryn_forms_send_emails
will send all emails that are waiting to be sent.
Add these commands to crontab:
1/10 * * * * django-admin aldryn_forms_remove_expired_post_idents 1/10 * * * * django-admin aldryn_forms_send_emails