On Tuesday, December 4, 2018 at 4:40:30 AM UTC-8, Arindam Dasgupta wrote:
>
> Hi,
> I need to display a drop down list in my form but have no idea how to do
> it. I have the following arrangements :
>
> Model :
>
> db.define_table('orders',
>
> Field('comments' ,type='string'),
> Field('print_size',requires=IS_IN_SET(['5x3.5', '6x4',
> '6x4.5', '5x7', '5x7.5', '6x8', '6x9', '12x8', '12x10',
> '12x12', '12x15', '12x18', '12x24', '12x30',
> '12x36']),default='6x4'),
>
> Field('paper_type',requires=IS_IN_SET(['Matte','Glossy']),default='Matte'),
> Field('copies',requires=IS_IN_SET(mylist),default=1),
> Field('cart',type='boolean' ,default='False'),
> Field('checkout',type='boolean' ,default='False'),
> Field('pic_upload' ,'upload',autodelete=True),
> Field('order_id' , type='integer',default= 0),
> Field('price' , type='float' , default=1),
> Field('unit_price' , type='float' , default=1),
> Field('order_status' ,
> requires=IS_IN_SET(['Delivered','Not Delivered']) , default='Not
> Delivered'),
>
> auth.signature
> )
>
> Controller :
>
> def multiple_upload():
> import datetime
>
> form = FORM(LABEL("File(s):"), INPUT(_name='pic_upload', _type='file',
> _multiple=''),
> BR(), LABEL("Comments:"), INPUT(_name='comments'),
> BR(), LABEL("Print Size:"), INPUT(_name='print_size'),
> BR(), LABEL("Paper Type:"),INPUT(_name='paper_type'
> ,requires=IS_IN_SET(['Matte','Glossy']) ),
> BR(), LABEL("copies:"), INPUT(_name='copies'),
> BR(),INPUT(_type='submit'))
>
> return dict(form=form)
>
>
> View:
>
> {{extend 'layout.html'}}
> <h1>This is the default/multiple_upload.html template</h1>
> {{=form}}
>
> In the paper type field I need to display a drop down with values ('Matte'
> , 'Glossy').
> Can you please show me how to do that.I dont want to use SQL form or
> SQLFORM.FACTORY .
> Thanks in advance for your kind suggestions.
>
> Best Regards,
> Arindam
>
SQLFORM() does dropdown lists for fields where requires=IS_IN_DB() is set.
I haven't bothered much with other form helpers or with straight HTML forms.
/dps
--
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/d/optout.