I think it is a method of SQLFORM. FORM() is a web2py helpers, it unique role is generate html. SQLFORM is another beast. Maybe further reading of the book could help you better understand the difference : http://web2py.com/books/default/chapter/29/07/forms-and-validators
Richard On Wed, Sep 25, 2013 at 3:34 PM, Warren Block <[email protected]> wrote: > And it's only just now I realize that "months" is a set, not a list. > Changing it to ['January', ...] solves the order. > > I'm still curious why add_button does not work with a simple FORM(), > though. > > > On Wed, 25 Sep 2013, Warren Block wrote: > > 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<http://github.com/web2py/web2py>(Source >>> code) >>> - >>> https://code.google.com/p/**web2py/issues/list<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 >>> web2py+unsubscribe@**googlegroups.com<web2py%[email protected]> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/**web2py >>> <http://github.com/web2py/web2py>(Source code) >>> - >>> https://code.google.com/p/**web2py/issues/list<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 >>> web2py+unsubscribe@**googlegroups.com<web2py%[email protected]> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >> > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/**web2py <http://github.com/web2py/web2py>(Source > code) > - > https://code.google.com/p/**web2py/issues/list<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 > web2py+unsubscribe@**googlegroups.com<web2py%[email protected]> > . > For more options, visit > https://groups.google.com/**groups/opt_out<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.

