Thanks. I decided against the first issue because as per the application I am porting from Java EE to web2py, there'd be some overheads with that route.
With regards to the second issue, I added a function to the insert and update hooks to update any company set that is set as default if the new record to be inserted has is_default set to true. def set_all_default_company_to_false(fields): if fields.get('is_default'): rows = db(query).select(db.company.id) for row in rows: where I simply pass in the fields dict that is passed to functions in the update and insert hooks. Thanks for your response. db(db.company.id == row.id).update(is_default=False) On Monday, 18 January 2016 16:51:44 UTC, DenesL wrote: > > Hello Seraaj > > 1) You can still use SQLFORM if you want, just preset the widget and use > the fields parameter of SQLFORM to filter: > > def someaction(): > db.table.fieldX.widget = SQLFORM.widgets.autocomplete(request, ...) > form = SQLFORM(db.table, fields=['fieldX',], ...) > if form.validate(): > # do something with the form's data > > > or you can use SQLFORM.factory: > > form = SQLFORM.factory( db.table.fieldX.clone(...) ) > > 2) Set the default for the is_default field to False > and check if there is a record in the db with is_default==True and a > different id that the current insert/update in the accepted portion of your > form processing, and set it to False. > > Denes. > > On Sunday, January 17, 2016 at 6:33:56 PM UTC-5, Seraaj Muneer wrote: >> >> Hello everyone from Accra Ghana. >> >> I've a small issue I'm not sure how to go about. >> >> I've a number of companies in the database. What I want to do is create a >> form with just a select field containing the companies in the database, and >> naturally a submit button to post the form to a controller. How do I use >> the Autocomplete widget outside of SQLForm? Is it even possible? If not, >> how do I represent the list of companies in HTML in a way that the user >> will not have to scroll endlessly to select a company as would be the case >> with a traditional HTML select? >> >> Also every company entity in the database has a boolean field, >> 'is_default', now how do I make sure only one company has 'is_default' set >> to True? So all others have it as False? Also if upon inserting or updating >> a company, the new or updated record has 'is_default' set to True, then I >> want to set that of all other companies as False. >> >> >> >> >> Thanks >> >> >> -- 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.