I want to implement a dhtmlxForm and want to use validation and selectOptions.
When submitting the form and the field Name is left empty, but has validate=“NotEmpty” it still is updated to the database.
For the selection, it is not the correct selected value (not bound like in bound=provinceID which is not working)
The sources:
formMarkers.html
[code]
#cont div {
width:350px;
height:30px;
}
#cont div input, select {
float:right;
width:250px;
}
.dhxlist_obj_dhx_skyblue label{
color:#000000;
font-family:Tahoma;
font-size:11px;
}
.dhxlist_obj_dhx_skyblue .dhxlist_txt_textarea, input.dhtmlx_validation_error{
border: 1px solid #A4BED4;
padding: 1px 0;
}
<body>
<div id="cont" style="height:350px;">
<form action="" method="post" accept-charset="utf-8" id="my_form" onsubmit="return myForm.validate();" >
<div>
<label>Name: </label><input class="dhxlist_txt_textarea" validate="NotEmpty" bind="name" type="text" name="field_a" value="">
</div>
<div>
<label>Address: </label><input class="dhxlist_txt_textarea" bind="address" type="text" name="field_b" value="">
</div>
<div>
<label>Province: </label><select connector="options.php" name="field_c" id="field_c"></select>
<!-- <input class="dhxlist_txt_textarea" bind="provinceID" type="text" name="field_c" value=""> -->
</div>
<div>
<label>Phone: </label><input class="dhxlist_txt_textarea" bind="phone" type="text" name="field_d" value="">
</div>
<input type="submit" value="Save data">
</form>
<script>
var myForm = new dhtmlXForm("my_form");
//myForm.bindField("field_c","provinceID");
var dp = new dataProcessor("data.php");
dp.init(myForm);
</script>
<input type="button" name="" value="load data #3" onclick="myForm.load('data.php?id=3');">
<input type="button" name="" value="load data #4" onclick="myForm.load('data.php?id=4');">
<input type="button" name="" value="load data #5" onclick="myForm.load('data.php?id=5');">
</div>
</body>
[/code]
data.php
[code]<?php
$res = mysql_connect(“host”,“user”,“password”);
mysql_select_db(“database”);
require_once('../dhx/dhtmlxForm/codebase/connector/form_connector.php');
$form = new FormConnector($res);
provinces", “province_id”, “province_id(value),province_name(label)”);
$form->enable_log("log.txt");
$form->render_table("markers","marker_id","name,address,provinceID,phone");
?>[/code]
options.php
[code]<?php
$res = mysql_connect(“host”,“user”,“password”);
mysql_select_db(“database”);
require_once('../dhx/dhtmlxForm/codebase/connector/options_connector.php');
$options = new SelectOptionsConnector($res);
$options->render_sql("SELECT province_id, province_name FROM provinces", "province_id", "province_id,province_name");
?>[/code]