Buy Now
Sign in

CF6 Custom code for AutoComplete

andreasuriani , December 18 2017
A
andreasuriani
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?
    admin
    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
    If your main question got answered then please mark the answer using the button!​
    ​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
    A
    andreasuriani

    Any helps or any examples...?

    admin

    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
    If your main question got answered then please mark the answer using the button!​
    ​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!