Hello,
I have been having success with V5 except for one thing that I can't manage - which is a double dropdown using dynamic options.
I started from the FAQ here:
http://www.chronoengine.com/faqs/70-cfv5/5232-how-do-i-build-a-dynamic-drop-down-in-cfv5.html
and the first dropdown works fine. But I can't make the second one work.
I followed the FAQ above and created the dynamic options, and the new event with the DB Read and the Custom Code (I thought) suitably adapted. The new event is triggered in the Event section of dropdown1.
However I found that the conditions area of the DB Read is not working as I expect. If I use a fixed condition:
<?php
return array( 'Member_Name' -> 'Smith');
?>
it works. But if I try to select based on the content of the first dropdown:
<?php
return array( 'Member_Name' -> '$form->data['dropdown1']');
?>
Then it seems to ignore the condition and select all records.
My second problem is in the Custom Code of the Ajax event, which I placed in the On Found section of the DB Read.
This code looks like this:
The result is a simple list of all member names in the table, not the selection I tried to get in the DB Read; and I expected a result like
email@example.com=John Smith and what I got was just 'John Smith'.
So I'm a bit puzzled. Obviously most of the code is working, so the answer is probably simple.
Thank you
Tim
I have been having success with V5 except for one thing that I can't manage - which is a double dropdown using dynamic options.
I started from the FAQ here:
http://www.chronoengine.com/faqs/70-cfv5/5232-how-do-i-build-a-dynamic-drop-down-in-cfv5.html
and the first dropdown works fine. But I can't make the second one work.
I followed the FAQ above and created the dynamic options, and the new event with the DB Read and the Custom Code (I thought) suitably adapted. The new event is triggered in the Event section of dropdown1.
However I found that the conditions area of the DB Read is not working as I expect. If I use a fixed condition:
<?php
return array( 'Member_Name' -> 'Smith');
?>
it works. But if I try to select based on the content of the first dropdown:
<?php
return array( 'Member_Name' -> '$form->data['dropdown1']');
?>
Then it seems to ignore the condition and select all records.
My second problem is in the Custom Code of the Ajax event, which I placed in the On Found section of the DB Read.
This code looks like this:
<?php
$options = array();
if ( !$form->data['model_name'] || count($form->data['model_name']) < 1 ) {
// no result was found
$options[] = 'Please select a category';
} else {
foreach ( $form->data['model_name'] as $d ) {
$options[$d['Email']] = $d['Member_Name'];
}
}
echo json_encode($options);
?>
The result is a simple list of all member names in the table, not the selection I tried to get in the DB Read; and I expected a result like
email@example.com=John Smith and what I got was just 'John Smith'.
So I'm a bit puzzled. Obviously most of the code is working, so the answer is probably simple.
Thank you
Tim