Problems using connector and processor with Dhtmlxform

Hello,

I’ve spent most of today trying to get my form to load, and also to get the form to update the database. I’m sure there is something I’m doing wrong, but I’ve looked at the documentation and samples, and can’t figure it out.

Here is the form:

[code]

Constructed form






var dp;
var formData;
var myForm;
function doOnLoad() {
formData = [{
type: “input”,
name: “Title”,
label: “Title”,
value: “”,
width: “750”,
bind: “title”
}, {
type: “input”,
name: “Description”,
label: “Description”,
value: “”,
width: “750”,
bind: “code”
}, {
type: “input”,
name: “Justification”,
label: “Justification”,
value: “”,
width: “750”,
bind: “lvl”
}
];

		myForm = new dhtmlXForm("myForm",formData);
		myForm.load("myFormConnector.php?code='1008A695'");
		dp = new dataProcessor("myFormConnector.php");
		dp.setTransactionMode("POST",true)
		dp.init(myForm);
		
	    }
	    
	    
	dhtmlxError.catchError("ALL",function(a,b,data){
	    //data[0] - request object
	    alert(data[0].responseText); // - incorrect server side response
	    //alert(data[0].status);
	});
	
	function saveData() {
		dp.save();
	}
	
        </script>
</head>
<body onload="doOnLoad();">

	<div id="myForm"></div>
	<input type="button" value="Save data" command="save" onclick="javascript:saveData();">
	</div>

</body>
[/code]

Here is the PHP connector:

[code]<?php
require_once(“/dhtmlxSuite/dhtmlxConnector/codebase/db_sqlsrv.php”);
require_once(“/dhtmlxSuite/dhtmlxConnector/codebase/form_connector.php”);

$serverName = "CH-SQL-6\Pentamation_rpt";
$uid=file_get_contents("C:\inetpub\wwwroot_DEV\uid.txt");
$pwd=file_get_contents("C:\inetpub\wwwroot_DEV\pwd.txt");

$connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>"COF_Objects_Dev", "LoginTimeout"=>15); // <- SS authentication
$res = sqlsrv_connect( $serverName, $connectionInfo); // <- SS authentication

if($res)
{
    echo "Connection established.\n";
}
else
{
    echo "Connection could not be established.\n";
    die( print_r( sqlsrv_errors(), true));
}

$form = new FormConnector($res,"SQLSrv");
$form->render_sql("SELECT title, code, lvl FROM proj_title","code","title, code, lvl","");  

/* Close the connection. */
sqlsrv_close($res);
echo “Connection closed.\n”;
?>[/code]

And here are my questions:

  1. Do I use the data connector to UPDATE the database table from the form, or can I use just the connector for both SELECT and UPDATE?

  2. Do I use one PHP connector file to SELECT and another one to UPDATE the database?

  3. How do I tell the form to load a specific record? I tried

myForm.load("myFormConnector.php?code='1008A695'");

where the record ID is ‘1008A695’, but it didn’t work; all fields are empty after form load.

  1. How do I tell the form to save changes? Clicking on the SAVE button produces a JavaScript error, ‘Object doesn’t support this method’ at
myForm.load("myFormConnector.php?code='1008A695'");

Thank you for your help.

hi:

you need this lines

<script src="../dhtmlxForm/codebase/dhtmlxdataprocessor.js"></script>
<script src="../dhtmlxForm/codebase/connector/connector.js"></script>

Thanks, sickeiros, but if you check my code samples, those two files were already in there.

Stanislav, are you there? Anyone at DHTMLX? Some answers would be really welcomed. I’ve just about ran out of time on my project trying to make the form work, and may have to drop your product and just write the app in PHP.

Thanks.

(1) you can use the same connector file for both operations

(2) can be organized in such way, but has not sense in most cases.

(3)
myForm.load(“myFormConnector.php?id=‘1008A695’”); //always id, without relation which field is real primary key

(4)
instead of

function saveData() { dp.save(); }
you can use

function saveData() { myForm.save(); }

Спасибо, Станислав.

Unfortunately, my boss has indicated I’ve run out of time on this project trying to get the DHTMLX form control to work. I’m now writing the web app in PHP.

I will try our solutions after the app is finished. I also have an upcoming project for which I would like to use the DHTMLX grid control - it seems to be powerful and a more mature product than the form control.

Until then, thank you once more.