Big form widgets refactor to allow user-defined widgets, added number widgets#991
Merged
Merged
Conversation
mdipierro
reviewed
Aug 14, 2025
…idget (for all blobs or specific fields)
…atching to allow proper overwriting
Contributor
Author
|
I've changed a few things.
|
Contributor
|
Nice work! |
laundmo
added a commit
to laundmo/py4web
that referenced
this pull request
Sep 22, 2025
…ed number widgets (web2py#991)" This reverts commit a1f6238.
mdipierro
pushed a commit
that referenced
this pull request
Oct 19, 2025
…ed number widgets (#991)" (#1001) * Reapply "Big form widgets refactor to allow user-defined widgets, added number widgets (#991)" This reverts commit a1f6238. * fix: add forgotten instantiation of new-style widgets * Clarify in docs that FormStyleDefault should be cloned before modifying * add tests for FormStyle.widgets backwards compat, and fix discovered issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was quite unsatisfied with the stats of FormStyleFactory and Form widgets. Especially when it comes to extending/overwriting them, the options were sparse - basically limited to overwriting them per field.
This PR is a pretty big refactor for Widgets and how they work.
widget.make()wasn't used before, instead a default readonly formatting was applied to basically any field.Widget.make()still exists, its primarily called byform_htmlwhich is what creates the div/label structure used for comments, errors, etc. This allows user-defined widgets to change where in the HTML comments, errors, labels etc. appear.self.field,self.varsetc. when they need this information. This makes it far easier to work with custom logic compared to all of this logic being inFormStyleFactory.field.widgetandformstyle.widgetsoptions, which is done through implementing custom Widget subclasses to handle those.Since this is a big and somewhat opinionated refactor, I haven't written documentation, exhaustive comments, and tests yet. Before I put that work in I'd want to know whether there's any chance this might be merged.