Adding hidden field to a form

676 views
Skip to first unread message

Joseph Jude

unread,
Sep 28, 2011, 10:14:40 PM9/28/11
to web...@googlegroups.com
Hi,
I define the below form in controller but the hidden field is not present in the view. Note that, field 'totalitems' is not in the db. Let me know how to add hidden fields to FORM.

form = FORM(
DIV(
LABEL("Checklist Items:"),
UL(
SPAN(INPUT(_type="text", _name="citems"), 
IMG(_class="add", _src=URL('static', 'images/add.png')), 
IMG(_class="remove",_src=URL('static', 'images/delete.png'))),
),
hidden=dict(totalitems='1')
))
Thank you,
Joseph

Anthony

unread,
Sep 28, 2011, 10:22:53 PM9/28/11
to web...@googlegroups.com
I think the 'hidden' argument goes inside FORM() -- looks like you've got it inside DIV().

Anthony

Roberto Perdomo

unread,
Sep 29, 2011, 9:17:29 AM9/29/11
to web...@googlegroups.com
Do the form normally and try this with jquery:

    $('#totalitems').hide();

2011/9/28 Anthony <abas...@gmail.com>

Cliff

unread,
Sep 29, 2011, 3:05:07 PM9/29/11
to web2py-users
Why not use the session to carry that value forward? If you put it
into the browser you really need to validate it, under the general
security rule of not trusting anything that comes from the browser.

Also I believe LABEL helper should be used differently. It renders an
html label tag.

Here's a reference:
http://www.w3schools.com/tags/tag_label.asp

On Sep 29, 9:17 am, Roberto Perdomo <roberto...@gmail.com> wrote:
> Do the form normally and try this with jquery:
>
>     $('#totalitems').hide();
>
> 2011/9/28 Anthony <abasta...@gmail.com>
>
>
>
> > I think the 'hidden' argument goes inside FORM() -- looks like you've got
> > it inside DIV().
>
> > Anthony
>
> > On Wednesday, September 28, 2011 10:14:40 PM UTC-4, Joseph Jude wrote:
>
> >> Hi,
> >> I define the below form in controller but the hidden field is not present
> >> in the view. Note that, field 'totalitems' is not in the db. Let me know how
> >> to add hidden fields to FORM.
>
> >> form = FORM(
> >> DIV(
> >> LABEL("Checklist Items:"),
> >> UL(
> >> SPAN(INPUT(_type="text", _name="citems"),
> >> IMG(_class="add", _src=URL('static', 'images/add.png')),
> >> IMG(_class="remove",_src=URL('**static', 'images/delete.png'))),

puercoespin

unread,
Oct 4, 2011, 9:53:33 AM10/4/11
to web2py-users
Not sure that's your asking for:

INPUT(_type='hidden', _name='_hiddenName', _value='hiddenValue')

TheSweetlink

unread,
Oct 5, 2011, 1:34:07 AM10/5/11
to web2py-users
I believe your FORM needs a totalitems field or INPUT. At least
that's what I experienced with SQLFORM.factory.

Needed a Field('totalitems', readable=False, writable=False) to match
if I was passing hidden=dict(totalitems='1').

I often choose SQLFORM or .factory for the ability to customize the
form in the view with CSS.

I have not tested this but perhaps adding an INPUT(_type='hidden',
_name='totalitems', _value='1') to your FORM may work.

Maybe look into SQLFORM and SQLFORM.factory http://web2py.com/book/default/chapter/07

Best of luck and I'm sure at least one genius on this list will have
the answer if I wasn't of any help, this community is almost
unbelievably helpful...almost :)

-David
Reply all
Reply to author
Forward
0 new messages