Yes, you have to include the options in the SELECT() -- the SELECT() 
doesn't know it should get the options from the IS_IN_DB validator.

Anthony

On Sunday, October 7, 2012 3:01:48 PM UTC-4, dave wrote:
>
> ok I got it to display using select() 
>
> SELECT(_type='text', _name='test0',  requires=IS_IN_DB(db, db.tiers.type, 
> '%(type)s'))) 
>
> now the problem is it wont populate the options of the dropdown box from 
> the database, my tiers database is defined like
>
> db.define_table('tiers', 
>             Field('type'))
>
>
> On Sunday, October 7, 2012 7:33:54 AM UTC-7, Anthony wrote:
>>
>> There are two separate issues -- the validation of the submitted values, 
>> and the widget displayed in the form to input the values. In your case, the 
>> validation should still work, but you won't get the widget because the 
>> widget is added by the SQLFORM __init__ method, which is called before you 
>> add the additional field. If you want a dropdown, you'll have to insert a 
>> SELECT() element instead of an INPUT() element.
>>
>> Anthony
>>
>> On Sunday, October 7, 2012 5:44:48 AM UTC-4, dave wrote:
>>>
>>> I have the following code
>>>
>>> def test():  # gets fired for first page load, it loads the filter 
>>> applicants form on the left side
>>>     form = SQLFORM(db.auth_user, request.args(0), buttons=[], separator 
>>> = ' ', formstyle = 'divs', deletable=True, fields = ['test1', 'test2', 
>>> 'test3'], upload=URL(r=request, f='download'), showid = False)
>>>     
>>>     # this line of code adds a test dropdown box to the filter 
>>> applicants form, because it is not part of the auth_user field, it needs to 
>>> be added separately
>>>     test0 = TR(LABEL('test 0'), 
>>>                       INPUT(_type='text', _name='test0', requires=
>>> IS_IN_DB(db, db.tiers.type)))
>>>     form[0].insert(1,test0) # 1 is the position where it will be added
>>>     # end of inserting code
>>>
>>> the problem is the input box wont show a dropdown box as expected, it 
>>> only shows a blank text box, is it a bug or am I missing something
>>>
>>

-- 



Reply via email to