You do not need to use FORM() and INPUT() helpers just because you need to 
construct some custom markup for the form. Instead, use SQLFORM as usual 
and use the form.custom.widget widgets it generates to compose your form, 
as described here: 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms.
 
You can use those widgets either in the view within custom HTML (as shown 
in the book), or inside the FORM() helper if you really prefer that method.

You can also generate just the SELECT widget as follows:

SQLFORM.widgets.options.widget(db.quotation.customer, quote_row.customer)

Anthony

On Thursday, June 22, 2017 at 6:34:54 AM UTC-4, Rudy wrote:
>
> Hi there,
>
> Due to the javascript reason, i need to create a form using FORM and INPUT 
> helper. I wonder how I can create a form using these helpers with field 
> displaying a dropdown list for selection (of customer from quotation form)? 
> Below is a simplified version, currently i created autocomplete to display 
> a list of customer names matched the input text while user is typing. 
> Thanks in advance!
>
> db.define_table('customer',
>                 Field('customer_name', requires=[IS_NOT_EMPTY()]),
>                 format='%(customer_name)s')
> db.define_table('quotation',
>                 Field('customer', 'reference customer'),
>                 Field('project_name', requires=IS_NOT_EMPTY()),
>                 Field('total', 'double', default=0),
>                 auth.signature)
>
> quote_row = db.quotation(id)
> quotation_form = FORM(
>                 'Quotation id:', INPUT(_type='number', _name='id', _value=
> quote_row.id, _id='quotation_id', _readonly='True', 
> requires=IS_NOT_EMPTY()),BR(),
>
>                 #'Customer Name:', INPUT(_type='number', _name='customer', 
> _value=quote_row.customer, _id='quotation_customer', requires=IS_IN_DB(db, '
> customer.id', '%(customer_name)s')),BR(),  DIV(_style="position: 
> absolute;", _id="suggestions", _class="suggestions"), BR(),
>                 'Customer Name:', INPUT(_type='text', _name='customer', 
> _value=db.customer(quote_row.customer).customer_name, 
> _id='quotation_customer', requires=IS_IN_DB(db, 'customer.id', 
> '%(customer_name)s')),BR(), DIV(_style="position: absolute;", 
> _id="suggestions", _class="suggestions"), BR(),
>
>                 'Project Name:', INPUT(_type='text', _name='project_name', 
> _value=quote_row.project_name, _id='quotation_project_name'),BR(),
>                 'Total:', INPUT(_type='number', _step='0.01', 
> _name='total', _value=quote_row.total, _id='quotation_total', 
> _readonly='True'),BR(),
>                 INPUT(_type='submit'))
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to