Support horizontal and inline form layouts#282
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.__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.
Can you add a comment here why this is done as it is being done?
There was a problem hiding this comment.
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_classcan be set toform-horizontalorform-inlineto 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
deform2branch onto the currentmaster. See #187 for further notes and context.