Problem populating form select options from DB connector.

Hi Folks,

I’m just getting my feet wet with dhtmlx, and I’m having some trouble populating a form’s select box options from my database via the form connector. This seems very basic, and I think perhaps I’ve missed something.

Upon page load, in one of the cells, a blank form is loaded, which contains only a single select box.

ksForm = eveLayout.cells(“b”).attachForm();

The form looks like this:

<?xml version="1.0" encoding="UTF-8"?>

I have an event in the grid on this page that’s supposed to populate the options of the select box from the database:

hostGrid.attachEvent(“onRowSelect”, function(rID){

Here’s the guts of that …

$dbh = mysql_connect(“localhost”,“root”,“xxxxxx”);

$hostid = $_REQUEST[‘id’];

$formConn = new FormConnector($dbh,“MySQL”);
$optsConn = new OptionsConnector($dbh);
$optsSQL = "select as value, as label from kickstarts ".
"inner join distro_kickstarts on distro_kickstarts.kickstartid = ".
"inner join distros on = distro_kickstarts.distroid ".
“inner join hosts on hosts.distroid = where = $hostid”;
$optsConn->render_sql($optsSQL, “”, “value,label”);

$formConn->set_options(“id”, $optsConn);

… now, thanks to the firebug plugin in Chrome, I can see what data is being returned:

<?xml version='1.0' encoding='utf-8' ?>

These are the options that I expect… but… these options don’t get populated in the select box in the form.

What might I be missing with how this works?



FormConnector and OptionsConnector can not be used at once.

FormConnector generates the xml with form values. OptionsConnector returns xml with select options.

To define path to xml with options (or php script that generates it) you can use connector attribute in “select” config:

path to xml with form data is defined in load() method:


Thanks for the info… that helped me reason this out.

One last thing I’m running into is a method for choosing the “selected” option. What the queries in my original post were attempting to do was create a list of all options available to the host, then set the “selected” option to the current value in the database.

I was able to do something similar for the host grid… but I can’t seem to find the correct magic for this in my form. Could you pass me another clue?



the option will be selected after data loading - the option that correspond item value will be seleced. Or you can set combo value using setItemValue method.

SelectOptionsConnector doesn’t allow to define “selected” attribute for an option.