-
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
Open
dairiki
wants to merge
5
commits into
Pylons:main
Choose a base branch
from
dairiki:form-layouts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
78a2dd3
Support for .form-horizontal and .form-inline layouts
dairiki f8c666c
Only put description in title if it is not otherwise displayed.
dairiki 8c4cda6
Support passing explicit column_classes argument to serialize() for M…
dairiki 05e340c
Omit 'required' class on structural (empty) labels
dairiki 3b619d6
Change Field.clone() to preserve .parent
dairiki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,60 @@ | ||
<div tal:define="error_class error_class|field.widget.error_class; | ||
description description|field.description; | ||
title title|field.title; | ||
oid oid|field.oid; | ||
hidden hidden|field.widget.hidden; | ||
category category|field.widget.category; | ||
structural hidden or category == 'structural'; | ||
required required|field.required;" | ||
description description|field.description; | ||
title title|field.title; | ||
oid oid|field.oid; | ||
hidden hidden|field.widget.hidden; | ||
category category|field.widget.category; | ||
structural category == 'structural'; | ||
required required|field.required; | ||
|
||
form field.get_root(); | ||
form_class form_class|string:${form.widget.css_class or form.css_class or ''}; | ||
horizontal form_class == 'form-horizontal'; | ||
inline form_class == 'form-inline'; | ||
column_classes column_classes|field.parent.widget.column_classes; | ||
left_column_class column_classes[0]|'col-xs-12'; | ||
right_column_class column_classes[1]|'col-xs-12'; | ||
label_class (not horizontal or column_classes) and 'control-label' or ''; | ||
label_class inline and 'sr-only' or label_class;" | ||
class="form-group ${field.error and 'has-error' or ''} ${field.widget.item_css_class or ''}" | ||
title="${description}" | ||
id="item-${oid}" | ||
tal:omit-tag="structural" | ||
tal:attributes="title inline and description or None" | ||
tal:omit-tag="hidden or (structural and not horizontal)" | ||
i18n:domain="deform"> | ||
|
||
<label for="${oid}" | ||
class="control-label ${required and 'required' or ''}" | ||
tal:condition="not structural" | ||
class="${label_class} ${horizontal and left_column_class or ''} ${required and not structural and 'required' or ''}" | ||
tal:condition="not (hidden or (structural and not horizontal))" | ||
id="req-${oid}" | ||
> | ||
${title} | ||
<tal:span tal:condition="not structural">${title}</tal:span> | ||
</label> | ||
|
||
<div tal:define="input_prepend field.widget.input_prepend | None; | ||
input_append field.widget.input_append | None" | ||
tal:omit-tag="not (input_prepend or input_append)" | ||
class="input-group"> | ||
<span class="input-group-addon" | ||
tal:condition="input_prepend">${input_prepend}</span | ||
><span tal:replace="structure field.serialize(cstruct).strip()" | ||
/><span class="input-group-addon" | ||
tal:condition="input_append">${input_append}</span> | ||
</div> | ||
|
||
<p class="help-block" | ||
tal:define="errstr 'error-%s' % field.oid" | ||
tal:repeat="msg field.error.messages()" | ||
i18n:translate="" | ||
tal:attributes="id repeat.msg.index==0 and errstr or | ||
('%s-%s' % (errstr, repeat.msg.index))" | ||
tal:condition="field.error and not field.widget.hidden and not field.typ.__class__.__name__=='Mapping'"> | ||
${msg} | ||
</p> | ||
<div class="${right_column_class}" tal:omit-tag="hidden or not horizontal"> | ||
<div tal:define="input_prepend field.widget.input_prepend | None; | ||
input_append field.widget.input_append | None" | ||
tal:omit-tag="not (input_prepend or input_append)" | ||
class="input-group"> | ||
<span class="input-group-addon" | ||
tal:condition="input_prepend">${input_prepend}</span | ||
><span tal:replace="structure field.serialize(cstruct).strip()" | ||
/><span class="input-group-addon" | ||
tal:condition="input_append">${input_append}</span> | ||
</div> | ||
|
||
<p tal:condition="field.description and not field.widget.hidden" | ||
class="help-block" > | ||
${field.description} | ||
</p> | ||
<p class="help-block" | ||
tal:define="errstr 'error-%s' % field.oid" | ||
tal:repeat="msg field.error.messages()" | ||
i18n:translate="" | ||
tal:attributes="id repeat.msg.index==0 and errstr or | ||
('%s-%s' % (errstr, repeat.msg.index))" | ||
tal:condition="field.error and not hidden and not field.typ.__class__.__name__=='Mapping' and not inline"> | ||
${msg} | ||
</p> | ||
|
||
<p tal:condition="field.description and not hidden and not inline" | ||
class="help-block" > | ||
${field.description} | ||
</p> | ||
</div> | ||
</div> |
This file contains 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
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.
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.