dynamic dropdown list with a condition

Filter a CF dropdown list by category.

Overview

The dropdown was showing all content because the SQL query lacked a WHERE condition.
In the DB Read action's Conditions box, add the correct PHP code without extra spaces to filter by category ID.

Answered
Ch ChDUP 15 May, 2014
Hi.

I'm using ChronoForm 5.
I would like to display in a dropdown list all my content included in a specific category.
For the moment, with the action "DB read", my select shows all my content (id and title) in table joomla_content.
I would like to add a condition "WHERE catid = xx" to the SQL request.

How to do this ?
Thanks for your help.
Gr GreyHead 15 May, 2014
Hi ChDUP,

Use the Conditions box in the DB Read action. You will need a condition like:
<?php
return array('catid' => 'xx');
?>

Bob
Ch ChDUP 15 May, 2014
Thanks GreyHead.
But I've already tried, and it just write
< ?php
return array('catid' => 31);
?>
in the front office, above the front.
And my dropdown isn't affected.
I've tried with and without the "<?php ... ?>" code.
I don't understand how conditions works.
Gr GreyHead 15 May, 2014
Answer
Hi ChDUP,

It needs to be in the Conditions box as I said.

I'm sorry, there was a typo in my code, an extra space in <?php :-(

Bob
Ch ChDUP 16 May, 2014
Oh, no it's my fault, I haven't see the space too.
I made the same mistake in my first try, for sure.
It's because there's an extra space in the admin, in the sample, just bottom the conditions box.
So, copy-past are wrongs !

Thanks !
This topic is locked and no more replies can be posted.