Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Sep 16, 2015

With these changes, FormWidget.css_class can be set to form-horizontal or form-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 current master. See #187 for further notes and context.

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@miohtama
Copy link
Contributor

miohtama commented Jun 2, 2016

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

  • Horizontal forms is a feature that should go into Deform core

Things I'd like to discuss

  • Would it be possible to move some of template functionality to a separate template (e.g. horizontal-form.pt) to maintain the core set of templates more minimal, clean and especially free from variables and conditional checks

If this is an abandon pull request and there is no new feedback I will close this pull request in 30 days.

@stevepiercy
Copy link
Member

I'm preparing a Deform 3.0 release. If someone would like to complete this PR, per @miohtama's comments, I will include it.

@stevepiercy
Copy link
Member

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.

Base automatically changed from master to main January 19, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants