I just recently added:
db.Item.image.requires = IS_IMAGE()
The records that existed prior to adding this line does not obey the
IS_IMAGE() (ie: they still allow me to upload a PDF). All new records
created DO work - they force me to select an image or else they show
an error.
steps to reproduce (untested)
1) create DB
db.define_table('Item',
Field('description'),
Field('need', 'boolean'),
Field('image', 'upload'))
2) add rows to the table
3) add rules:
db.Item.category.requires = IS_IN_DB(db, db.Category.id,'%(name)s')
db.Item.description.requires = IS_NOT_EMPTY()
db.Item.image.requires = IS_IMAGE()
4) go back to the rows you added to the Item table and add non-image
files - notice it works
Does that help?
On Jul 11, 11:42 am, mdipierro <[email protected]> wrote:
> Please tell us more. When do you get an error? What is the error?
>
> On 11 Lug, 11:57, Rob <[email protected]> wrote:
>
>
>
> > This issue only happens for records that were created before I added
> > the .requires fields. Error handling on new records works as
> > expected... so... is it still a bug?
>
> > On Jul 11, 9:15 am, Rob <[email protected]> wrote:
>
> > > db.define_table('Category',
> > > Field('name'))
>
> > > db.define_table('Item',
> > > Field('category', db.Category),
> > > Field('description'),
> > > Field('need', 'boolean'),
> > > Field('image', 'upload'))
>
> > > db.Item.category.requires = IS_IN_DB(db, db.Category.id)
> > > db.Item.description.requires = IS_NOT_EMPTY()
> > > db.Item.image.requires = IS_IMAGE()
>
> > > def details():
> > > item = request.args(0)
> > > form = crud.update(db.Item, item, next=URL(r=request, args=item))
> > > return dict(form=form)
>
> > > It allows me to upload PDFs and flashes 'record updated'