Forums

autocomplete, assignment of different values

vismay 14 Jun, 2017
Hello,

I see the power of chronoform 6, but I'm far away to be able to use it!

My question:

I've settled up an autocomplete field ( dropdown_field), that read a database of 3 columns: column A, column B, column C.

column C is primary index.

The form return the right value in dropdown_field.

I need to do this special feature:

According to the choice of dropdown_field ( lets say the column A) , I need to assign to another hidden field the corresponding value of column B and to another field the corresponding value of column C.

Any idea?

Thanks
GreyHead 14 Jun, 2017
Hi vismay,

You can either just use the primary key then look up the other values after the form submits; or you can concatenate the value like this 99#column_a#column_b and then break that string apart again after the form submits.

Bob
vismay 14 Jun, 2017
Thanks, I will try to "digest" your suggestion....
vismay 16 Jun, 2017
I canoni really figure it out.

this code is working perfectly on chronoform 5 but on 6 doesn't work:

$db =& JFactory::getDBO();
$com = $form->data['comune'];
$query = "
    SELECT `codice`
        FROM `tab_comuni`
        WHERE `descrizione` = '{$com}' ;
";
$db->setQuery($query);
$comune_cod  = $db->loadResult();


$comune_cod is not assigned

I also change $form->data['comune'] with {data:comune} but same result.

Any suggestion?
Thanks in advance
GreyHead 18 Jun, 2017
Hi vismay,

In CFv6 Max has changed $form->data to $this->data

Also more recent versions of PHP will warn about the =& Use $db = \JFactory::getDBO(); instead

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