See
http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910
.
On Friday, April 27, 2012 11:00:44 AM UTC-4, cory n wrote:
>
> This works, after I submit once, then my selection for FIELD1 appears in
> FIELD2. I need it to operate before a submit though, so that once a
> "Segment" is selected, I can use that selection in the other dropdown boxes
> before a submit.
>
> Thanks
>
> Cory
>
> On Friday, April 27, 2012 8:13:58 AM UTC-5, Massimo Di Pierro wrote:
>>
>> IS_IN_SET(getFamilies(form.vars.Segment))))
>>
>> should be
>>
>> IS_IN_SET(getFamilies(request.vars.Segment))))
>>
>> but I would not set this validator in models, I would set it in
>> controller function, where needed.
>>
>> On Thursday, 26 April 2012 12:54:26 UTC-5, cory n wrote:
>>>
>>> Okay, I want to make the second field of a SQLFORM.factory depend on
>>> what is chosen in the first field... something like this...
>>>
>>> form = SQLFORM.factory(
>>> Field('PN', requires=IS_NOT_EMPTY()),
>>> Field('Segment', requires=IS_IN_SET(['Segment1', 'Segment2'])),
>>> Field('Family',
>>> requires=IS_IN_SET(getFamilies(form.vars.Segment))))
>>> ...
>>>
>>> Of course I can't use form.vars.Segment until the form is submitted, so
>>> how can I accomplish this?
>>>
>>> So that the field 'Family' takes the value of the field 'Segment', does
>>> a calculation and returns the appropriate list of families.
>>>
>>> I'm super new to web programming, so I apologize in advance if this is a
>>> dumb question.
>>>
>>>
>>>
>>>
>>>
>> On Thursday, 26 April 2012 12:54:26 UTC-5, cory n wrote:
>>>
>>> Okay, I want to make the second field of a SQLFORM.factory depend on
>>> what is chosen in the first field... something like this...
>>>
>>> form = SQLFORM.factory(
>>> Field('PN', requires=IS_NOT_EMPTY()),
>>> Field('Segment', requires=IS_IN_SET(['Segment1', 'Segment2'])),
>>> Field('Family',
>>> requires=IS_IN_SET(getFamilies(form.vars.Segment))))
>>> ...
>>>
>>> Of course I can't use form.vars.Segment until the form is submitted, so
>>> how can I accomplish this?
>>>
>>> So that the field 'Family' takes the value of the field 'Segment', does
>>> a calculation and returns the appropriate list of families.
>>>
>>> I'm super new to web programming, so I apologize in advance if this is a
>>> dumb question.
>>>
>>>
>>>
>>>
>>>