Using placeholder in List Pre-filter: my error or fabrik error?

marcelf

Member
I'm trying to use pre-filter. I need to the records that are too old using the a value of a field element.

First like in the fabrik wiki I tried:
http://fabrikar.com/forums/index.php?wiki/list-pre-filters/

> Show records created before the estimated days to do the job (overdue)
where:
field = your-date-element
condition: less than
value: NOW()- INTERVAL '{jobs_estimated_days)' HOUR
type=no quotes

It didn't work. '{jobs_estimated_days)' isn't recognized using "no quotes".

So I tried to use EVAL. My Problem: the placeholder isn't working in the pre-filter value. Look the filter below.

pre-filter with placeholder.JPG I also created calc field to test with same code. It shouldn't show any record, but its showing:
list-results.JPG

In the calc works, but in the value using EVAL of pre-filter don't. Is it a Fabrik bug ?

Another solution: how can I store the result of calc when the list is viewed?

Thanks,
Marcel
 
I think this placeholder not work in pre-filter.
If your placeholder {documentos___id} is rowid on the pre-filtered list you can try with {rowid}.
If not right then use sql query.
Note:
in field value don't use return.
 
Hi,

I just tried {rowid} with all types (EVAL, query and no quotes) and it doesnt work.

I also already use return when EVAL is configured and it works for me:

$prazo=10; return date('Y-m-d H:i:s', strtotime("-$prazo months"));

But, the $prazo cant be a constant, it is an element in the form. So placeholder doesnt work:

$prazo='{assuntos___prazo}'; return date('Y-m-d H:i:s', strtotime("-$prazo days"));

How can I use SQL?
I dont understand in the wiki:
http://fabrikar.com/forums/index.php?wiki/list-pre-filters/
"Then {$q->a} can be used as a placeholder in the value field."


Should type be configured as Query in this case? But I need get the date today and subtract with period ($prazo), is this possible using Query?

Thank you for reply,
Marcel
 
In field Pre-filter query type your select query.
"Select id, parent_id from tablename where ...."
Then in field value you can get results from query like:
{$q->id} or {$q->parent_id}
 
Where is your 'jobs_estimated_days' field coming from?

You can't use normal element placeholders in a pre-filter, because ... well, it's a PRE filter. It's setting up the WHERE clause used to select the rows from your table. So at the point that WHERE clause is being built, we haven't yet loaded any of the rows, so there are no element values. Chicken and egg.

Also ... a pre-filter is a single WHERE clause used to select all the rows to display from the table. So even if we could magically know the value of a field we are about to select before we select it ... which row's value would we use?

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top