The IS_IN_DB etc didn't work for me -- perhaps I did something wrong -- but
the variations with IS_IN_SET do. Thanks!
On Saturday, September 8, 2012 2:46:24 AM UTC-4, rochacbruno wrote:
>
> maybe this?
>
> form = SQLFORM.factory(
> Field('test',
> type='string',
> requires=IS_IN_DB(*db(db.table.field == xyz)*, db.city.name_url,
> '%(name)s', multiple=True),
> widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
> style='divs'),
> default = 'New-York'), formstyle='divs')
>
> or
>
> myset = [("value 1", "text 1"), ("value 2", "text 2"), ("value 2", "text
> 2")]
>
> form = SQLFORM.factory(
> Field('test',
> type='string',
> requires=IS_IN_SET(myset, multiple=True),
> widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
> style='divs'),
> default = 'New-York'), formstyle='divs')
>
> or
>
> myset = {"value 1": "text 1", "value 2": "text 2", "value 2": "text 2"}
>
> form = SQLFORM.factory(
> Field('test',
> type='string',
> requires=IS_IN_SET(myset, multiple=True),
> widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
> style='divs'),
> default = 'New-York'), formstyle='divs')
>
> or
>
>
> myset = db.executesql("SELECT value, text FROM sometable")
>
> form = SQLFORM.factory(
> Field('test',
> type='string',
> requires=IS_IN_SET(myset, multiple=True),
> widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
> style='divs'),
> default = 'New-York'), formstyle='divs')
>
>
> *Bruno Cezar Rocha** - @rochacbruno*
> [email protected] <javascript:> | Mobile: +55 (11) 99210-8821
> www.CursoDePython.com.br | www.rochacbruno.com.br
> Blog: Using Python to get all the external links from a
> webpage<http://rochacbruno.com.br/using-python-to-get-all-the-external-links-from-a-webpage/>
> Get a signature like this.
> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
> Click
> here.<http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>
>
>
>
> On Sat, Sep 8, 2012 at 3:22 AM, Mike Girard <[email protected]<javascript:>
> > wrote:
>
>> I have a checkboxes widget which I invoke like so:
>>
>> form = SQLFORM.factory(
>> Field('test',
>> type='string',
>> requires=IS_IN_DB(db, db.city.name_url, '%(name)s',
>> multiple=True),
>> widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
>> style='divs'),
>> default = 'New-York'), formstyle='divs')
>>
>> I use requires=IS_IN_DB solely to populate the checkboxes with fresh
>> data. I don't really need the validation. Now I would prefer to spread the
>> data in the one table being used across multiple checkbox groups. Is there
>> an out-of-the-box way to populate form elements with queries instead of
>> just binding them to tables?
>>
>> --
>>
>>
>>
>>
>
>
>
--