There is a way:

1) remove the dropdown while still doing validation serverside:

db.order.product.requires = [IS_IN_DB(db,'product.id','%(name)s')]

(By having the validator in a list, it will not create the dropdown)

2) add autocomplete:

db.order.product.widget = SQLFORM.widgets.autocomplete(request, 
db.field.name, db.product.id)



On Monday, 15 October 2012 12:28:22 UTC-5, VP wrote:
>
> Let's say I have these 2 tables:
>
> product = db.define_table('product', Field('name'))
> order = db.define_table('order', Field('product', db.product))
>
> Now, when you do something like this:
>
> form = SQLFORM(db.order)
>
> The product field will be a drop down list of products for you to choose. 
>   This is nice if you have dozen product entries or so.  But if you have 
> 10000 products, it's impractical to select from the drop down list, and 
> further it unloads a truck-load of text (although invisible) on the page. 
>  This is not only impractical it is also very inefficient in both bandwidth 
> and time.
>
> I think a sensible way for the developer to do is having another mechanism 
> to select product.  But even if, you do something like this:
>
> db.order.product.default = product_id_selected_in_some_way
>
> the form created by SQLFORM *stills* unloads 10000 entries.
>
> My suggestion is there ought to be a way to stop SQLFORM from 
> automatically do this by default.  Perhaps there is a way already, but I 
> couldn't find it combing through the online doc.
>
>
>
>
>

-- 



Reply via email to