This generates a random-hashed order also (although I had to add more months to see it):

    months = {'January', 'February', 'March', 'April', 'May', 'June'}
    buttons = []
    for month in months:
        buttons.append(TAG.button(month, _type="button"))
    form = SQLFORM.factory(db=None, buttons=buttons)

That may not be what you meant.

On Wed, 25 Sep 2013, Richard Vézina wrote:

Why not using SQLFORM.factory() and get the new buttons attributes that let you 
manage as many buttons as you want? It also let you manage buttons positions 
much more easilly then
manipulate the generated form.
Richard


On Wed, Sep 25, 2013 at 1:17 PM, Warren Block <[email protected]> wrote:
      Trying to generate a small form that is all buttons:

      def month-example:
          months = {'January', 'February', 'March'}

          form = FORM()
          for month in months:
              # this fails
              form.add_button(month, URL(month))
          return dict(form=form)

      This generates 'NoneType' object has no attribute 'parent'.

      Creating links with helpers works:

              form += A( month, _href=URL(month) )

      But the form is a dictionary, and the months are out of order.  I think 
that add_button preserves the order, but have not verified that.

      Does add_button only work with SQLFORM?

      How can the order of elements added to a form programmatically be 
controlled?

      --
      Resources:
      - http://web2py.com
      - http://web2py.com/book (Documentation)
      - http://github.com/web2py/web2py (Source code)
      - https://code.google.com/p/web2py/issues/list (Report Issues)
      --- You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
      To unsubscribe from this group and stop receiving emails from it, send an 
email to [email protected].
      For more options, visit https://groups.google.com/groups/opt_out.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to