Hello,
I have some dropdowns that I want to populate in the onload of my form.
So started to build a test form to see how i could populate a datapath for a dynamic dropdown.
I added the following in a Custom Code action in on the onload of the form to be executed in the controller:
Got a debug after this code to see the data.
However when i test this form i get and error. But as soon as I remove the following lines
The debug is getting showed with the values of the arrays.
What I'm doing wrong here? Any idea why this is not working?
I have some dropdowns that I want to populate in the onload of my form.
So started to build a test form to see how i could populate a datapath for a dynamic dropdown.
I added the following in a Custom Code action in on the onload of the form to be executed in the controller:
<?php
$db2conn = array();
$db2conn['driver'] = 'mysql';
$db2conn['host'] = 'localhost';
$db2conn['user'] = '...';
$db2conn['password'] = '...';
$db2conn['database'] = '...';
$db2conn['prefix'] = '';
$db2 = & JDatabase::getInstance($db2conn);
$query = "select * from teams";
$db2->setQuery($query);
$db2->query();
$form->data['playdate'] = $db2->loadAssocList();
$form->data['End'] = 'End of DB Loads';
?>
Got a debug after this code to see the data.
However when i test this form i get and error. But as soon as I remove the following lines
$db2->query();
$form->data['playdate'] = $db2->loadAssocList();
The debug is getting showed with the values of the arrays.
What I'm doing wrong here? Any idea why this is not working?
Hello,
put the two lines in comment and added some values manually to test my dynamic dropdown box and this seems to be working ok.
So what I'm doing wrong to read my external db?
put the two lines in comment and added some values manually to test my dynamic dropdown box and this seems to be working ok.
//$db2->query();
//$form->data['playdate'] = $db2->loadAssocList();
$form->data['playdate'][0]['value']=1;
$form->data['playdate'][0]['text']='een';
$form->data['playdate'][1]['value']=2;
$form->data['playdate'][1]['text']='twee';
$form->data['playdate'][2]['value']=3;
$form->data['playdate'][2]['text']='drie';
$form->data['playdate'][3]['value']=4;
$form->data['playdate'][3]['text']='vier';
So what I'm doing wrong to read my external db?
Hi,
How stupid can a man be....
Found the culprit and I'm the only one to blame.
Did my test with a non populate db table.
Learned my lesson (half day), so as of now I will start to build also some error checking in my tests.
Should save me time in future tests.
Oef, on to the next hurdle.
How stupid can a man be....
Found the culprit and I'm the only one to blame.
Did my test with a non populate db table.
Learned my lesson (half day), so as of now I will start to build also some error checking in my tests.
Should save me time in future tests.
Oef, on to the next hurdle.
This topic is locked and no more replies can be posted.