Forums

CF6 Custom code for AutoComplete

andreasuriani 18 Dec, 2017
Hi there,
in CF5 I have this code to run the event "Autocomplete":

<?php
include "file_include/master.php"; 

$db->setQuery("SELECT  * FROM $ana_intranet WHERE check_conguagliato IS NULL ORDER BY nominativo ASC");
$results = $db->loadObjectList();
foreach($results as $result ){
	if(!empty($form->data['tag']) AND stripos($result->nominativo, $form->data['tag']) === false){
		continue;
	}
	$json[] = array('id' => $result->codice_fiscale."_".$result->cod_azie, 'text' => $result->nominativo." (".$result->denominazione_azienda.")".$result->data_lic);
}
echo json_encode($json);


Unfortunatly, in CF6 it doen't work at all.

I've tried to change $form->data to $this->data but nothing changed.

Any help?
Max_admin 29 Jan, 2018
Hi Andrea,

Apologizes for the late reply!

In v6 the auto complete code should return a value/text array, no "id" or "text" keys should be used, so your code needs to be modified a bit to work.

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 06 Feb, 2018
Hi Andrea,
This line:
$json[] = array('id' => $result->codice_fiscale."_".$result->cod_azie, 'text' => $result->nominativo." (".$result->denominazione_azienda.")".$result->data_lic);
should be:
$json[] = array($result->codice_fiscale."_".$result->cod_azie => $result->nominativo." (".$result->denominazione_azienda.")".$result->data_lic);
Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.