-
Notifications
You must be signed in to change notification settings - Fork 161
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
Support horizontal and inline form layouts #282
base: main
Are you sure you want to change the base?
Conversation
I'd be all for renaming Form.bootstrap_form_style to something shorter. (Also, I think it makes more sense as an attribute of FormWidget rather than of Form.) Deform_bootstrap uses Form.bootstrap_form_style, however, so compatibility considerations may be warranted.
(to prevent lonely red asterisk)
The reasons for this (and some alternatives) are listed at Pylons#187 (comment)
cloned = self.__class__(self.schema) | ||
cloned.__dict__.update(self.__dict__) | ||
cloned.order = next(cloned.counter) | ||
cloned.oid = 'deformField%s' % cloned.order | ||
cloned._parent = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here why this is done as it is being done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not looked at this in years, so have forgotten anything I knew about this.
I am just now starting to look at it again. I think this comment explains the need for being able to access the parent of the cloned field.
Thank you for your pull request. I am the new Deform project maintainer. I apologize the issue of this pull request not being commented earlier. Deform project is again under activate maintenance. This is issue tracker / pull request clean to prepare a new release. I am willing to merge this pull request. However I hope to have some discussion first. Things I agree
Things I'd like to discuss
If this is an abandon pull request and there is no new feedback I will close this pull request in 30 days. |
I'm preparing a Deform 3.0 release. If someone would like to complete this PR, per @miohtama's comments, I will include it. |
I've assigned this PR to the Deform 2.1.0 milestone. For Deform 3.x, we will have a new repository for custom Deform templates that implement horizontal layouts and any other widget that is not provided with Deform. |
With these changes,
FormWidget.css_class
can be set toform-horizontal
orform-inline
to trigger bootstrap's alternative form layouts.For horizontal forms the columns widths are controlled by a new setting MappingWidget.column_classes (a two-tuple of CSS classes).
Within a horizontal form, if .column_classes is a false value, classes will be set in order to simulate the default "vertical" layout for that mapping (this involves setting both the label and control columns widths to col-xs-12 and omitting the control-label class from the control label.) By default MappingWidget.column_classes is None, while FormWidget.column_classes is not, so that the top level form will be laid out horizontally, while any nested mappings will use a faux-vertical layout. (This complication is necessary since, within a .form-horizontal, all .form_groups must be structured in the horizontal style (with columns).)
This is PR #187 rebased from the defunct
deform2
branch onto the currentmaster
. See #187 for further notes and context.