More generally, all web2py HTML helpers (including FORM and SQLFORM) act
like Python lists with respect to their components, so you can use all the
Python list methods, including .insert and .append. Helpers also act like
Python dictionaries with respect to their attributes (i.e., named
arguments), so you can used dictionary methods like .update for attributes.
Subscripting works as expected as well.
See http://web2py.com/books/default/chapter/29/5#HTML-helpers.
Anthony
On Thursday, March 29, 2012 8:30:25 AM UTC-4, bussiere adrien wrote:
>
> Find i've adapted an exemple :
>
> form=FORM("UserName:", INPUT(_name='Username'),
> "Email : ", INPUT(_name='email',_value=user.email),
> INPUT(_type='submit'))
> form.insert(-1,INPUT(_name='titi',_value='titi'))
>
>
> the doc :
>
> Sometimes you may wish to add an extra element to your form after it has
> been created. For example, you may wish to add a checkbox which confirms
> the user agrees with the terms and conditions of your website:
>
> 1.
> 2.
> 3.
> 4.
>
> 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)
>
>
> Le jeudi 29 mars 2012 14:14:01 UTC+2, bussiere adrien a écrit :
>>
>> is there a way to dynamically create a for like :
>>
>> liste = ["titi","toto"]
>>
>> form=FORM("UserName:", INPUT(_name='Username'),
>> "Email : ", INPUT(_name='email',_value=user.email),
>> )
>>
>> for l in liste :
>> form.add("%s : "%l,INPUT(_name="%s"%l))
>> # and at the end add the submit button :
>> form.add(INPUT(_type='submit'))
>>
>>
>> Reagrds
>> Bussiere
>>
>>
>>