When you add an extra element this way, it gets inserted into the form 
object, but it does not get added to the items in form.custom.widget, 
form.custom.label, etc. (those are constructed when the form is first 
created). You have a couple options. In the view, you can simply refer to:

{{=form.element(_name='agree')}}

Or you can explicitly add to custom.widget and custom.label:

form = SQLFORM(db.yourtable)
form.custom.widget.my_extra_input = INPUT(_name='agree', value=True, _type=
'checkbox')
form.custom.label.my_extra_label = LABEL('I agree to the terms and 
conditions')
my_extra_element = TR(form.custom.label.my_extra_label, form.custom.widget.
my_extra_input)
form[0].insert(-1, my_extra_element)

Anthony

On Wednesday, June 6, 2012 7:45:38 AM UTC-4, rahulserver wrote:
>
> I added this extra element to my sqlform (as given in web2py book chapter 
> forms and validators):
>
> form = SQLFORM(db.yourtable)
> my_extra_element = TR(LABEL('I agree to the terms and conditions'), \
>                       INPUT(_name='agree',value=True,_type='checkbox'))
> form[0].insert(-1,my_extra_element)
>
> But when i tried to access it in view as 
> {{=form.custom.widget.my_extra_element}} (between form.custom.begin and 
> form.custom.end) i am getting a none instead of a checkbox.
>
> {{=form}} does give the output as desired. But i wish to make a few 
> customizations in the form so i am trying the custom form approachfo.So 
> what is the way to access the extra sqlform elements from views?
>

Reply via email to