Skip to content

Additional Extension Points in FormBuilder and FormFieldStreamBlock #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

rgs258
Copy link
Contributor

@rgs258 rgs258 commented Nov 18, 2020

This change just refactors the code a bit by creating new methods to override when subclassing FormBuilder or FormFieldStreamBlock for customization:

  • In FormBuilder, created: create_field_class and create_field_name
  • In FormFieldStreamBlock, created: instantiate_block
  • In BaseField, created: get_local_blocks
  • In BaseField, created: get_form_block_class
  • In BaseField, created: get_form_block_kwargs

Please let me know if there's anything else I can do to help this get merged. If you need me to write tests, if you can you please let me know what the signature of each test should be, I will fill in the blanks.

Thanks!

@rgs258 rgs258 changed the title Additional Extension Points in FormBuilder Additional Extension Points in FormBuilder and FormFieldStreamBlock Nov 18, 2020
@rgs258
Copy link
Contributor Author

rgs258 commented Mar 18, 2021

Merged #170

@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (02958f9) 95.65% compared to head (9a11923) 95.68%.
Report is 84 commits behind head on master.

❗ Current head 9a11923 differs from pull request most recent head 891b666. Consider uploading reports for the commit 891b666 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
+ Coverage   95.65%   95.68%   +0.03%     
==========================================
  Files          28       28              
  Lines         943      951       +8     
  Branches       85       85              
==========================================
+ Hits          902      910       +8     
  Misses         34       34              
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rgs258
Copy link
Contributor Author

rgs258 commented May 11, 2022

@leongraumans I wonder if this PR is appropriate for merge? If this'll never be picked up, that's totally fine, please just let me know and I can continue to maintain this work in my fork. Thanks

rgs258 added 3 commits April 4, 2023 14:53
# Conflicts:
#	setup.py
#	tests/hooks/test_process_form.py
#	tox.ini
# Conflicts:
#	wagtailstreamforms/blocks.py
#	wagtailstreamforms/forms.py
#	wagtailstreamforms/migrations/0001_initial.py
#	wagtailstreamforms/migrations/0003_alter_form_fields.py
#	wagtailstreamforms/models/form.py
@rgs258
Copy link
Contributor Author

rgs258 commented Dec 19, 2023

Caught up to labd's master and added a new extension point: get_local_blocks()

@rgs258
Copy link
Contributor Author

rgs258 commented Dec 19, 2023

@leongraumans I wonder if this PR is appropriate for merge? If this'll never be picked up, that's totally fine, please just let me know and I can continue to maintain this work in my fork. Thanks

bump, and thank you for maintaining this project!

@leongraumans
Copy link
Member

Hi @rgs258,

Happy new year, and apologies for the late reply! I'll come back to you later this week.

…e return of subclass of a structural block for further control over the block class, such as overriding the clean() method to provide custom validation.
@rgs258
Copy link
Contributor Author

rgs258 commented Jan 5, 2024

Added yet another extension point, get_form_block_class, to allow the return of subclass of a structural block for further control over the block class, such as overriding the clean() method to provide custom validation.

@rgs258
Copy link
Contributor Author

rgs258 commented Jan 5, 2024

I think I might share that we're using this package in a somewhat unconventional way. We've adapted it such that Pages themselves are the definition of the form. That is to say, we've made a subclass of Page for which the body StreamField has as local blocks all of the form elements registered to this package (in addition to the usual subclasses of FieldBlock). With this, an content author may create a page that itself is a form, and they may define that form inline with the page content. The Page, and the entire definition of the form, exist within the normal Wagtail system of revisions, permissions, workflow, previews (that was fun), etc.. This gives our content authors a great deal of freedom and allows out site to host ~2200 unique forms.

Its a dream of mine to extract the non proprietary parts of our adaptation and open source them as a bolt-on to this package. ...just got to find the time :)

…lf.get_form_block_class() and self.get_local_blocks() methods
@rgs258
Copy link
Contributor Author

rgs258 commented Jan 31, 2024

Adjusted wagtailstreamforms/wagtailstreamforms_fields.py to use new self.get_form_block_class() and self.get_local_blocks() methods

@rgs258
Copy link
Contributor Author

rgs258 commented Jan 29, 2025

Adjusted to a hatch project.

rgs258 and others added 3 commits March 17, 2025 14:39
Compatible Wagtail 6.3, Django 5.1
# Conflicts:
#	setup.py
#	wagtailstreamforms/models/form.py
…tibility

Updates the dependency requirements in the forked wagtailstreamforms package to:

- Change Wagtail version requirement from `>5.2,<=6.0.1` to `>6.0,<=6.3` to work with Wagtail 6 releases
- Replace `wagtail-generic-chooser` dependency with `wagtail-modeladmin` which is needed for Wagtail 6 compatibility
- Retain the Unidecode dependency unchanged

These changes align with upstream requirements and ensure compatibility with newer Wagtail versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants