ZTUtils.Zope make_hidden_input could preserve ordering

Bug #142944 reported by Dylan Jay
2
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Low
Unassigned

Bug Description

Sometimes ordering of inputs on forms is important.
make_hidden_input method uses a dict which is by default unordered. If a dict like object was passed in that was ordered then make_hidden_input will reorder it which isn't desirable. The following code retains the existing order. Perhaps another way to retain order is to pass in an optional list of keys which specifies the order.

 def make_hidden_input(*args, **kwargs):
    '''Redo ZTUtils.Zope.make_hidden_input so it orders things correctly '''
    if len(args) > 0:
        d = args[0].copy()
        for arg in args[1:]:
            d.update(arg)
    else:
        d = {}
    d.update(kwargs)

    hq = cgi.escape
    qlist = complex_marshal(d.items())
    for i in range(len(qlist)):
        k, m, v = qlist[i]
        qlist[i] = ('<input type="hidden" name="%s%s" value="%s">'
                    % (hq(k), m, hq(str(v))))

    return '\n'.join(qlist)

Tags: bugday
Tres Seaver (tseaver)
Changed in zope2:
status: New → Triaged
tags: added: bugday
removed: feature+solution zope
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.