ZTUtils.Zope make_hidden_input could preserve ordering

Reported by Dylan Jay on 2004-04-06
Affects Status Importance Assigned to Milestone
Zope 2

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 = {}

    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)

Tres Seaver (tseaver) on 2010-05-16
Changed in zope2:
status: New → Triaged
tags: added: bugday
removed: feature+solution zope
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers