klox7 VIP
Total posts: 914
22 Jul 2015 16:18

Hi,

I'm trying to create submission form with ChronoForms where I will have field for users to be able select existing records from Cobalt.

I was looking at render article list documentation but nothing was successfull. CjronoForm uses Autocompleter where you must enter your code.

They have this example:

<?php
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa");
foreach($countries as $country){
    if(!empty($form->data['tag']) AND stripos($country, $form->data['tag']) === false){
        continue;
    }
    $json[] = array('id' => $country, 'text' => $country);
}
echo json_encode($json);

I tried to do the same for records but something like this...:

<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = 'SELECT title FROM #__js_res_record WHERE type_id=1 AND published=1';
$db->setQuery($query);
$record_title = $db->loadObjectList();

foreach($record_title as $title){
    if(!empty($form->data['title']) AND stripos($title, $form->data['title']) === false){
        continue;
    }
    $json[] = array('id' => $title, 'text' => $title);
}
echo json_encode($json);
?>

...but without success. I'm I missing something.

Last Modified: 24 Jul 2015


Sergey
Total posts: 13,748
23 Jul 2015 13:25

try to change $db->loadObjectList(); to $db->loadColumn();


klox7 VIP
Total posts: 914
24 Jul 2015 09:21

That was it. Thank you!

Powered by Cobalt