To define options of the select item you should use SelectOptionsConnector on the server side and specify the connector parameter for the appropriate item on the client side:
client side:
var formData = [{type: "select", label: "Categories", connector:"selectOptions.php"}];
server side:
<?php
require_once("../codebase/connector/options_connector.php");
$res=new PDO("mysql:dbname=myDB;host=localhost","root","");
$data = new SelectOptionsConnector($res, "MySQL");
$data->render_table("categories","id","valueColumn, labelColumn");
?>
For more information on this topic, see 'SelectOptionsConnector' article.
To define options of the 'combo' item you should use ComboConnector on the server side and specify the connector parameter for the appropriate item on the client side:
client side:
var formData = [{
type: "combo",
name: "myCombo",
label: "Select type",
connector:"comboOptions.php"
}];
server side:
<?php
require_once("../codebase/connector/combo_connector.php");
$res=new PDO("mysql:dbname=myDB;host=localhost","root","");
$data = new ComboConnector($res, "MySQL");
$data->render_table("categories","id","valueColumn, labelColumn");
?>
$data->render_sql(
"SELECT *, CONCAT(FirstName, LastName) as label FROM table1",
"id",
"id,FirstName(label)"
);
Note, in the filtering mode Combo filters data by the "label" field.
To load data to a form you should use FormConnector on the server side and the method load (id) on the client side:
client side
myForm.load('formdata.php?id=1');
where a connector file with the id of loading record must be specified as the parameter.
The values of the record's columns will be used as the values of form's controls.
server side
<?php
require_once("../codebase/connector/form_connector.php");//includes needed connector
// connects to the "tasks" database
$res=new PDO("mysql:dbname=tasks;host=localhost","root","");
$conn = new FormConnector($res,"MySQL"); // connector initialization
$conn->render_table("customers","id","name, address, email"); // data configuration
?>
For more information on this topic, see 'dhtmlxForm.Work with the Server Side' tutorial.
To save form changes to DB, you should use the method save() on the client side.
You can call this method, for example, on clicking some button.
myForm.attachEvent("onButtonClick", function(id){
if (id=='saveButton'){
myForm.save();
}
}
For more information on this topic, see 'dhtmlxForm.Work with the Server Side' tutorial.
Back to top