Hi!
I followed this tutorial
http://www.icagenda.it/chronoforms-autocompleter-dati-da-tabella-db.html
It works great, I added a db save action to save the result, and this works well
But I would save my id field and not text
maybe there is something to be changed in the script, but I can not
then I ask for help.
thank you
I followed this tutorial
http://www.icagenda.it/chronoforms-autocompleter-dati-da-tabella-db.html
It works great, I added a db save action to save the result, and this works well
But I would save my id field and not text
maybe there is something to be changed in the script, but I can not
then I ask for help.
thank you
<?php
$lista_comuni = array();
if ( !$form->data['Datacom'] || count($form->data['Datacom']) < 1 ) {
// no result was found
$lista_comuni[] = 'Nessun comune è presente nella lista';
} else {
foreach ( $form->data['Datacom'] as $d ) {
$lista_comuni[$d['idComune']] = $d['idComune'];
$lista_comuni[$d['nomeComune']] = $d['nomeComune'];
}
}
foreach($lista_comuni as $un_comune){
if(!empty($form->data['tag']) AND stripos($un_comune, $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $un_comune, 'text' => $un_comune);
}
echo json_encode($json);
?>