SQLFORM col3 restrictions?

30 views
Skip to first unread message

Richard

unread,
May 31, 2009, 8:25:33 PM5/31/09
to web2py Web Framework
hello,

I am using the col3 argument to SQLFORM to add some data:
button = INPUT(_type='button', _value='test')
link = A('test', _href=URL(r=request, f='test'))
col3 = dict(name=button, project=link)
form = SQLFORM(db.model, col3=col3)

Strangely this works for links but not inputs. Inputs are not included
in the form - is there a reason for this? I am trying to add a button
to the form.
For now I am using the form[0][0][2].append(...) syntax but would
prefer to use the cleaner col3 argument.


Incidentally, could a HTML helper be added for BUTTON()? The CSS file
I use assumes I am using <button> rather than <input type='button'>.

thanks,
Richard

mdipierro

unread,
May 31, 2009, 10:08:54 PM5/31/09
to web2py Web Framework
This is very strange I fixed it and I am uploading the fix to trunk
but I do not understand it.
It seems that if INPUT() is false (?!)

You can use TAG.BUTTON(...)

Richard

unread,
May 31, 2009, 10:12:57 PM5/31/09
to web2py Web Framework
On Jun 1, 12:08 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> This is very strange I fixed it and I am uploading the fix to trunk
> but I do not understand it.
> It seems that if INPUT() is false (?!)

that's weird.
I found it works it I do SPAN(INPUT(...))

>
> You can use TAG.BUTTON(...)

thanks!

DenesL

unread,
May 31, 2009, 10:34:49 PM5/31/09
to web2py Web Framework

From the python 2.5 manual, library reference, 3.1:

"The following values are considered false:
...
instances of user-defined classes, if the class defines a __nonzero__
() or __len__() method, when that method returns the integer zero or
bool value False."

Both INPUT and A derive from DIV which has a __len__ method defined as
len(self.components).
INPUT's len is zero while A's is one, so combining than with the 'or'
in sqlhtml rev979 line 319 gives the above mentioned results.

Reply all
Reply to author
Forward
0 new messages