widget type lookup with custom SELECT

A place for users and developers of the Xataface to discuss and receive support.

widget type lookup with custom SELECT

Postby xyloweb » Thu Sep 20, 2012 6:16 am

Hi,

I use widget:type lookup and I want to know if it's possible to customize table select

Example : user table with contract end field > now()
xyloweb
 
Posts: 11
Joined: Tue Oct 11, 2011 5:27 am

Re: widget type lookup with custom SELECT

Postby shannah » Mon Sep 24, 2012 9:54 am

One solution would be to use the widget:filters:* directive and create a grafted field on the users table that is simply a boolean (0 or 1) value.
E.g.
In the users fields.ini file
Code: Select all
__sql__ = "select u.*, if(contract_end>now(),1,0) as contract_active from users u"


Then in your lookup widget field def

Code: Select all
[myfield]
    widget:type=lookup
    widget:table=users
    widget:filters:contract_active=1


Alternatively you could just create a view on the users table that includes only the users that you want in the lookup. Then reference that view from the lookup widget def instead of your actual users table.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: widget type lookup with custom SELECT

Postby xyloweb » Mon Sep 24, 2012 12:28 pm

Thanks steve for your reply.
I think a SQL view is an interesting response.

And many thanks for your great product !
xyloweb
 
Posts: 11
Joined: Tue Oct 11, 2011 5:27 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 25 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved