I *think* if you submit a form and immediately reload a new form (as part of 
the same action), the new form's dropdown is populated (via the IS_IN_DB 
validator) before the db insert of the submitted form, so the new form 
doesn't have the most up-to-date set of values. If that's the case, it 
should probably be fixed.

On Friday, October 21, 2011 9:28:38 AM UTC-4, Calycé wrote:
>
> Thanks a lot to both of you the IS_EMPTY_OR() was indeed what I was 
> needing (note to self: reread the book...) 
>
> Could anyone of you tell me when the the combo is populated ? I'm just 
> asking because now, when I enter a record using the appadmin 
> interface, the new record is not appearing in the combo but is 
> correctly inserted in the table. I have to reload the page in order to 
> see the last inserted category in the combo. 
>
>
> For the "0 or" it's a bad cut 'n paste... my bad. 
>
>
>
> On Oct 21, 2:56 pm, DenesL <dene...@yahoo.ca> wrote: 
> > Hi Calycé, 
> > 
> > note that: 
> > store.category.parent_category.requires = 0 or IS_IN_DB(db, 
> > db.category.id, '%(name)s') 
> > is equivalent to: 
> > store.category.parent_category.requires = IS_IN_DB(db, db.category.id, 
> > '%(name)s') 
> > since 0 evaluates to False. 
> > 
> > I believe that what you want is: 
> > store.category.parent_category.requires = IS_EMPTY_OR(IS_IN_DB(db, 
> > db.category.id, '%(name)s')) 
> > 
> > Denes. 
> > 
> > On Oct 21, 3:35 am, Calycé <welcome.t...@gmail.com> wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Hi all, 
> > 
> > > I have created a table with a self reference as described below: 
> > > db.define_table('category', 
> > >     Field('parent_category', 'reference category'), 
> > >     Field('name', 'string', length=40, required=True), 
> > >     Field('description', 'text', required=True), 
> > >     Field('small_image', 'upload')) 
> > 
> > > Now I'd like to have an "optional requires" clause. For example, if I 
> > > add the following clause "store.category.parent_category.requires = 0 
> > > or IS_IN_DB(db, db.category.id, '%(name)s')" I have a nice combo 
> > > whenever I use the appdadmin to insert rows BUT I have to select 
> > > something from the combo. In my case, the parent_category field should 
> > > be optional. In extenso, categories without parent_category would be 
> > > root categories so selecting a parent_category is optional. 
> > 
> > > Is there a way to present a combo as does the "requires" but without 
> > > enforcing the field ? Do I have to create a specific form for that ?

Reply via email to