Are you saying you want the form dropdown dynamically populated with a
subset of records based on the selection in a different field? If so,
you'll have to do that with Javascript and an Ajax call. See
http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910
for
some ideas.
Anthony
On Friday, March 8, 2013 2:34:56 AM UTC-5, Alex Glaros wrote:
>
> I want to limit IS_IN_DB to a table whose fields match what is being
> entered in an adjoining field in the same table.
>
> Tables:
>
> *Taxonomy* is the taxonomy type and contains the types of taxonomies,
> e.g., "plants" taxonomy, "computer languages" taxonomy.
>
> *TaxonomyData* is the detail taxonomy of each taxonomy type, e.g.,
>
> for "plants", it could have roses, acorn trees, rice, and,
>
> for "computer languages", it could have python, java, and perl.
>
> Taxonomy is the parent of TaxonomyData.
>
> *Suggestion* is a table of suggestions.
>
> *SuggestionCategorizationIntersection* table categorizes "Suggestion"
> data using Taxonomy and TaxonomyData.
>
> db.define_table('*Suggestion*'...)
>
> db.define_table('*Taxonomy*',
> Field('taxonomyShortName','string'),
> Field('taxonomyLongName','string'),
>
> db.define_table('*TaxonomyData'*,
> Field('taxonomyID','reference Taxonomy'),
> Field('taxonomyName','string'),
> Field('taxonomyDataID','string'),
> Field('taxonomyDataName','string'),
>
> db.define_table('*SuggestionCategorizationIntersection*',
> Field('suggestionID','reference Suggestion'),
> Field('taxonomyID','reference Taxonomy'),
> Field('taxonomyDataID','reference TaxonomyData'))
>
> Now if I use the code below, I get ALL of data in TaxonomyData, but I only
> want that data that matches what user typed in the adjoining TaxonomyID
> field in SuggestionCategorizationIntersection.
>
> db.SuggestionCategorizationIntersection.taxonomyDataID.requires =
> IS_IN_DB(db, db.TaxonomyData.id, '%(taxonomyDataName)s',zero=T('choose
> one')) ##<--- I get too much data
>
> I want to choose from taxonomyDataID data where the taxonomyID for it in
> TaxonomyData only matches the TaxonomyID the user is entering in
> SuggestionCategorizationIntersection.taxonomyDataID. These two fields are
> next to each other in SuggestionCategorizationIntersection.
>
> Ideally, I'd like to be able to do something like this:
>
> db.SuggestionCategorizationIntersection.taxonomyDataID.requires =
> IS_IN_DB(db, db.TaxonomyData.id WHERE TaxonomyData.taxonomyID =
> SuggestionCategorization.TaxonomyID
>
> The record hasn't been saved yet so how would web2py know what is in
> the SuggestionCategorization.TaxonomyID record user is typing in? See field
> colored red above.
>
> Can someone please write out the syntax for this "requires" clause?
>
> I'm testing in the appadmin.
>
> Thanks,
>
> Alex Glaros
>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.