Wagtail: New StreamField-based form builder

Created on 19 Apr 2018  路  3Comments  路  Source: wagtail/wagtail

This upcoming work is funded thanks to Wagtail鈥檚 first hatch, our first Kickstarter campaign! :tada:

It will be started after most of the work from #4473, most likely in August 2018.

This issue hosts all discussions about the features & API we want in this new form builder.

This work will be based on a form builder I built for a project as a Torchbox subcontractor. See it in action in one of the videos from the campaign. Here are the additional features provided by this new form builder compared to the existing one:

  • It is based on a StreamField instead of an InlinePanel, making it more flexible.
  • Easily create completely new field types.
  • Easily create multiple form builder models with completely different field types in it.
  • It supports files, and includes a special image block that generates thumbnails in the admin. All files (including generated thumbnails) are automatically removed when a submission is removed. They are not stored as Wagtail images or documents, but as regular Django files.
  • Each form consists in one or multiple steps, that can optionally be named.
  • Users can submit a form and modify its content later.
  • A Google-Drive-like autosave feature.
  • Each submission is stored in relation with a user, or a session object for anonymous users. That way, users can easily resume a form.
  • Extendable new admin based on ModelAdmin.

What needs to be changed before merge in Wagtail:

  • Add the possibility to create forms without steps.
  • Add the possibility to choose whether a form can be resumed or not.
  • Improve the new admin so it supports at least the same features as the current admin. The new admin has a limited date filter and no CSV export, but adds the possibility of custom filters & custom actions.
  • Improve the programmer interface, it started being a nice little API, but unfortunately the project specifications evolved a lot, and some parts are a bit messy. Nothing unorthodox, it鈥檚 just not easy to understand, so it needs work.
  • Improve the possibilities of the default form fields. For example, the equivalent of CharField has no possibility to specify a minimum or maximum length.
  • Add tests.
  • Add docs.

So there鈥檚 already a big chunk of work already done, but we鈥檙e not there yet.

Obviously, this new form builder will not be backwards compatible. So it will not replace directly the existing form builder, there will be one year or two where both builders will be supported at the same time. My idea is first to make it a third-party app, then integrate it as wagtail.contrib.stream_forms, at the same time deprecate wagtail.contrib.forms, and in Wagtail 3.0, ditch the old form builder and move wagtail.contrib.stream_forms to wagtail.contrib.forms.

Fixed issues

This work will implement solutions for at least these issues:

1348, #1556, #1564, #3001

Form builder NoriPyt2018 Enhancement

Most helpful comment

@johnraz Yes, please consider it as an alpha.
It is currently being tested in two projects with the current state, and after #4942 is merged I will adjust it to work best with the finally merged version of the React StreamField.
The React StreamField itself will be merged before the 1st of August, according to @gasman.

All 3 comments

This work got its first working version here: https://github.com/noripyt/wagtail-flexible-forms
It鈥檚 missing its documentation and still needs some cleaning, as well as tests.

Hello @BertrandBordage,

A few questions here:

Thanks a lot!

@johnraz Yes, please consider it as an alpha.
It is currently being tested in two projects with the current state, and after #4942 is merged I will adjust it to work best with the finally merged version of the React StreamField.
The React StreamField itself will be merged before the 1st of August, according to @gasman.

Was this page helpful?
0 / 5 - 0 ratings