Form won't save to table .. same code used no probs

Attached is code, site, sql tables, et all…
This is the minimum I can put together as an example. In fact the project has multiple windows, with layouts and views one with a table, and one view for the detail of the record. I’ve used the code sucessfully for at least another 10 tables. With this one it doesn’t save, but gives no errors. I’ve been hitting my head on it for a week, cutting the code down, re-writingit, but to no avail.

Please help, I’m really going crazy.
HelpOnPrevForm.rar (1.73 MB)

Hi

Tested localy:

  1. db created
  2. prevId set to -1
  3. open page and click “Save” button (w/o any editing, all inputs were empty)
  4. inserted successfuly

Edit your cnctFormPrev.php, rught after $form = new FormConnector($res);
add:
$form->enable_log(“path/to/file”)
dataproc will print some logs here.

Please reproduce issue and check logs. If any help will needed - attach log file here also
and some info regarding values in input fields which can’t be saved.

also there should be 2nd param - id, not *
$form->render_table(“prevent”,"*");

Thank you!
Especially for the trick to log… that will help very much, 'cause the “dhtmlxdataprocessor_debug.js” doesn’t say much, just “error”!

I have changed the render_table, but I can assure you, the
$form->render_table([tableName],"*");
works fine with all my other tables!

I changed the CnctFormPrev.php to :

<?php require_once("toitoi_config.php"); require_once("./dhtmlx/connector/codebase/form_connector.php"); $res=mysql_connect($mysql_server,$mysql_user,$mysql_pass); mysql_select_db($mysql_db); $form = new FormConnector($res); $form->enable_log("/toitoi/logs/") $form->render_table("prevent","PrevId","COD_FILIALE,ANNO,NUMERO,DATA,NOMINATIVO,INDIRIZZO,CITTA,PV,ATTENZIONE,PAGAMENTI,IVA,SPI,NF,DES_RAG_SOC1,DES_RAG_SOC2,IND_DEST,CITTA_DEST,CAP_DEST,PROV_DEST,LAT,LNG,REFERENTE,TELEF_DEST,DATA_DECO,DATA_REST_PR,INTERVALLO_P,TOTALE_SCONT,TRASPORTO,COSTO_SPURGO,TOTALE_EURO,TOTALE_IVA,TOTALE_OFFER,COMMENTO"); ?>

But the
$form->enable_log("/toitoi/logs/")
Which is a directory will “everyone” “full control” writes, as well as “IUSR…” full control, but the php stops working the moment I use the enable_log

You need to specify also filename here:
$form->enable_log("/toitoi/logs/")

OK, so you mean:

$form->enable_log("/toitoi/logs/logfile.txt")

Now I get (if I try to run the php, which I know I shouldn’t, or at least not without an “?id=…”), after I put:
$form = new FormConnector($res);
$form->enable_log("/toitoi/logs/dxlog.txt",true);

====================================
Log started, 30/04/2012 06:04:35

error_log(/toitoi/logs/dxlog.txt): failed to open stream: No such file or directory at C:\inetpub\wwwroot\toitoi\dhtmlx\connector\codebase\tools.php line 192

I’m having HUGE problems saving forms. Basically it’s on the validation of data:
IF there’s a NUMERIC or DATE db Field and the relative edit Box or Calendar is left blank then the form won’t save, and, what is worst, the form.save() gives NO message of this failure!

I’ve tried to put the debug line in the connector php, but it refuses it (as per previous message), I’ve tried checking the content of calendar fields ( form.getFieldValue(‘dateFrom’) ) and it returns NULL.

Please help on this matter!

See above posts: I tried to solve with the form validation. Unfortunately there’s NO way to validate a calendar:

I’ve inserted the following code:

var formDataPrev = [
	{type:'calendar', 	
            name: 'DATA',   
            validate:'ValidDatetime', 
            dateFormat: "%d/%m/%Y", 
            serverDateFormat: "%Y-%m-%d",				
            position:'absolute',	
             }, ... etc ...

  i've tried validatin with ValidDate, ValidDateTime etc ...

 I've attached the following handler...

prevForm.attachEvent("onValidateError", function (input, value, result){
	alert('input:' + input + '\r\nValue:' + value + '\r\nResult:' + result);
});

When I try to save, I get:


Message from webpage

input:DATA

Value:Wed May 2 10:05:09 UTC+0200 2012

Result:false

OK

As “Wed May 2 10:05:09 UTC+0200 2012” appears to be a perfectly good date, WHY is it validating to “false” ???

Hi

  1. ValidDatetime instructions:
    0000-00-00 00:00:00 to 9999:12:31 59:59:59 (no it is not a “valid DATE” function)
    you have Date object (when ValidDatetime waiting for string), you can add custom validate function:

var formDataPrev = [
{type:‘calendar’,
name: ‘DATA’,
validate: function(k){
return (k.toString() != “Invalid Date”);
},

}]

  1. regarding logs:
    tyr create empty text file dxlog.txt
    make sure path is valid

  2. form.getFieldValue(‘dateFrom’)
    sohuld be
    form.getItemValue(‘dateFrom’)

Thanks Andre

In some cases I have calendars on a form I want to leave empty (I do not know the date yet).

However if I leave it blank, the form.save() fails (althought it gives NO warning!)…

  1. How do you save to mysql db table the value “Null” from an empty calendar
  2. How can you be SURE that form.save() as succeeded?

Thank u in advance …

(1) you can define custom insert code for connector on server side

docs.dhtmlx.com/doku.php?id=dhtm … ex_updates

(2) you can use events of dataprocessor to catch the response and check its status

docs.dhtmlx.com/doku.php?id=dhtm … r_catching

Thank you Andrei that was VERY clear and conclusive.

While I have your attention, could you PLEASE clarify the versioning of the “dhtmlxform.js” file. Mine is one uploaded by your collegue recently, it is 79,4 KB (81.363 bytes) size, modified on ‎16 ‎aprile ‎2012, ‏‎17:38:08.

I’ve gone through many versions in the last 2 weeks, some don’t allow calendar controls to appear, others give errors on the validation. Which is the latest working “build”?

Sorry, doesn’t work:

I tried, very simply:
////////////////////////////

var myformData = [
{type:‘calendar’, label:‘Date’, validate:function(k){alert(k);}, {type:‘button’, id:‘btSave’, command:‘save’, value:‘Save’}
];

myform.attachEvent("onButtonClick",function(id,cmd) {//create event handler to save data on button click
    if(cmd=="save"){
		myform.validate();
	}
});

////////////////////////////////

If I try to type a date into the box instead of picking it, the “alert” comes up with null. Is there anyway I can both type in , and select from calendar a date?

Also it comes up “null” whether it is rubbish typed in (i.e. 44/77/1992) or blank, WHEREAS I want BLANK dates to be saved as NULL, and typed in ones to be properly checked!

Hi

Works fine localy.
Please check attachment - latest versions of calendar and form.
form_calendar.zip (308 KB)

OK, that’s all cleared up now…

Now I’m trying to solve the null date problems on the connector file, but I can’t get it right:
I’m trying to get the two calendars (“DATA_DECO” and “DATA_REST_PR”) to write NULL in the relevant date field of the table, if they are empty. I’ve tried a zillion combinations of $nullDate but none work…

<?php require_once("toitoi_config.php"); require_once("./dhtmlx/connector/codebase/form_connector.php"); $res=mysql_connect($mysql_server,$mysql_user,$mysql_pass); mysql_select_db($mysql_db); function checkUp($data){ // $nullDate = "NULL"; $nullDate = "0000-00-00"; $dtFr = $data->get_value("DATA_DECO"); if ($dtFr==NULL) $data->set_value("DATA_DECO",$nullDate); $dtTo = $data->get_value("DATA_REST_PR"); if ($dtTo==NULL) $data->set_value("DATA_REST_PR",$nullDate); } $form = new FormConnector($res); $form->enable_log("./logs/logFile.txt",true); $form->event->attach("beforeUpdate","checkUp") $form->render_table("prevent","PrevId","COD_FILIALE,ANNO,NUMERO,DATA,NOMINATIVO,INDIRIZZO,CITTA,PV,ATTENZIONE,PAGAMENTI,IVA,SPI,NF,DES_RAG_SOC1,DES_RAG_SOC2,IND_DEST,CITTA_DEST,CAP_DEST,PROV_DEST,LAT,LNG,REFERENTE,TELEF_DEST,DATA_DECO,DATA_REST_PR,INTERVALLO_P,TOTALE_SCONT,TRASPORTO,COSTO_SPURGO,TOTALE_EURO,TOTALE_IVA,TOTALE_OFFER,COMMENTO"); ?>

Save check:

I’ve added this:

var dpf = new dataProcessor("cnctFormPrev.php");//instatiate dataprocessor
dpf.init(prevForm);//link form to dataprocessor



dpf.defineAction("error",function(){
	alert('INCOMPLETE DATA');
	return(true);
});


dpf.defineAction("inserted",function(){
	alert('INSERTED');
	return(true);
});

dpf.defineAction("updated",function(){
	alert('INSERTED');
	return(true);
});

Now, if I get the data RIGHT the first save() then the data gets saved and the aler(“inserted”) comes up. If however there is an error in the data, then I get the INCOMPLETE DATA alert, but even if I correct it, nothing else happens. No alerts, and No Saving

Hi

Please confirm the following (what you trying to achieve):

  1. saving: check if date not set (i.e. date is null) - set date to 0000-00-00
  2. loading: if date is null - just show empty input on form, correct?

Will try to create a demo for you.

Yep, that’s right. But my problem is the following:
Example A

  1. I input correct data
  2. I click “save”
  3. Alert “inserted” pops up and data is saved

Example B

  1. I make mistake in data
  2. I click “save”
  3. Alert “Incorrect Data” pops Up
  4. I correct the data
  5. I click “save” again
  6. NOTHING happens, no alerts, no saving, nothing… button is “dead!”