Page 1 of 1

Validating a field by querying another table

PostPosted: Mon Oct 24, 2011 3:09 am
by rleyba
Hi Steve,

I have a requirement wherein before a record is saved in my 'Devices' table, the 'Devicename' field in this table will query another table (called 'Masterlist') containing the masterlist of devices and then NOT save the record if the device is not on that Masterlist. I saw this posting --> http://xataface.com/documentation/how-t ... validation but it doesn't do a table lookup of another table.

I can't use a dropdown list (widget) since the devices list could be many thousands of records long and it will annoy the users if they have to scroll down the list each time.

I looked up the Wiki but couldn't find a relevant post. Could you point me in the right direction?

thanks very much.

Re: Validating a field by querying another table

PostPosted: Mon Oct 24, 2011 1:59 pm
by shannah
Why not use a lookup widget for this? The lookup widget doesn't load all the options, it allows the user to filter results from another table.

Re: Validating a field by querying another table

PostPosted: Wed Oct 26, 2011 4:09 am
by ADobkin
Steve, on a related note, should the lookup widget dynamic filter option work in the currently released version 1.3rc6? I'd like to use it in some of my tables, but I couldn't seem to make it work. The wiki page indicates that it requires version 1.3.1. Is that correct?

http://xataface.com/wiki/lookup

Thanks,
Alan

Re: Validating a field by querying another table

PostPosted: Wed Oct 26, 2011 9:43 am
by shannah
It is not in 1.3rc6. It is, however in the 1.3.x SVN branch.

Re: Validating a field by querying another table

PostPosted: Thu Oct 27, 2011 9:00 pm
by ADobkin
shannah wrote:It is, however in the 1.3.x SVN branch.


Are you sure it is in 1.3.x? I don't see any mention of the dynFilters option in HTML/QuickForm/lookup.php in the latest 1.3.x SVN branch (rev. 2888). However, I do see it in the 1.5.x SVN branch.

I would migrate to either 1.3.x or 1.5.x for this feature based on your recommendation, but I had the impression that 1.5.x is not considered safe/stable for production use.

Re: Validating a field by querying another table

PostPosted: Fri Oct 28, 2011 9:20 am
by shannah
Looks like you're right. 1.5.x really is a snapshot from the trunk half-way through 2.0 development. I created it because I had some clients running straight off the trunk and I wanted to "freeze" the state of their version to prevent accidentally updating.

Re: Validating a field by querying another table

PostPosted: Wed Nov 02, 2011 12:49 am
by ADobkin
Okay, thanks. I decided to take the plunge and migrate to 1.5.x, because my application really needs this feature. I have found two bugs so far. I have added both to the tracker:

0000897: Errors generated with validators:maxlength = 0

0000906: Lookup widget dynamic filter ignored when adding new related record