Issue 2551065
Created on 2019-10-07 04:25 by garth, last changed 2019-10-08 12:43 by schlatterbeck.
msg6706 |
Author: [hidden] (garth) |
Date: 2019-10-07 04:25 |
|
Using tal:attributes with tal:replace="structure context/submit"
doesn't actually add attributes to the resulting submit button. This
makes it impossible to style the button by adding a class attribute.
The reason this happens is that context/submit returns two or three
hidden inputs before the submit input. The attributes assigned by
tal:attributes get attached to the first (hidden) input instead of the
submit input. The fix is to make the submit input get returned first
in the HTMLClass.submit and _HTMLItem.submit methods in templating.py.
|
msg6707 |
Author: [hidden] (schlatterbeck) |
Date: 2019-10-07 09:34 |
|
Can you give us an example of what you're trying to do?
Have you tried patching the method that generates the submit button?
I currently have no idea if context/submit calls a method, but if so,
wouldn't it make more sense to add some parameters so that you can style
the button (e.g. adding a default class that can be changed by a parameter).
|
msg6712 |
Author: [hidden] (garth) |
Date: 2019-10-07 19:06 |
|
I'm trying use Bootstrap to give my tracker a responsive interface.
It works mostly through specifying designated class attributes on
html tags.
One place I'm running into the problem is on the button for
submitting changes when editing an issue. This button is generated
in issues.item.html by the tag: <span tal:replace="structure
context/submit">submit button</span>. The context/submit part
returns the submit button and the associated @action and @csrf
hidden fields:
<input type="hidden" name="@csrf"
value="afeeb2035b1440efd94c85cda88e322c29f83d531e030785bdd53fdf89a8e
52b">
<input type="hidden" name="@action" value="edit">
<input type="submit" name="submit_button" value="Submit Changes">
To make the button styled per Bootstrap, I need to attach the
attribute `class="btn btn-primary"` to the last input tag. The only
hope I have for doing that is by using tal:attributes on the
original tag as follows:
<span>tal:replace="structure context/submit" tal:attributes="class
string:btn btn-primary">submit button</span>.
Of course it didn't work originally because the class attribute gets
attached to the first tag, which isn't the submit button.
context/submit gets delegated to either the HTMLClass.submit or
_HTMLItem.submit methods in templating.py. I went ahead and changed
the order of tags returned by those methods, and that seemed to do
the trick. The patch file is attached.
|
msg6715 |
Author: [hidden] (schlatterbeck) |
Date: 2019-10-08 12:43 |
|
Thanks, I've forward-ported the patch to the upcoming release 2.X, we'll
probably not backport it to another 1.6.X maintenance release.
Ralf
|
|
Date |
User |
Action |
Args |
2019-10-08 12:43:34 | schlatterbeck | set | status: new -> fixed resolution: accepted messages:
+ msg6715 |
2019-10-07 19:06:29 | garth | set | files:
+ templating.py.patch keywords:
+ patch messages:
+ msg6712 |
2019-10-07 09:34:54 | schlatterbeck | set | messages:
+ msg6707 |
2019-10-07 09:31:53 | schlatterbeck | set | nosy:
+ schlatterbeck |
2019-10-07 04:25:30 | garth | create | |
|