Getting data out of an dhtmlXForm that is in a dhtmlXLayout

I’m having problems trying to get data from a dhtmlXForm when using a dhtmlXLayout. I need to do this because according to docs.dhtmlx.com/doku.php?id=dhtm … orm_server I can “wrap dhtmlxForm conatinaer [sic] with HTML form tags and use HTML form submit to send data to server in common way”. The example shows a simple wrapping of the tag around a

and then creating the dhtmlXForm object using that div’s ID. However with a layout object you use attachForm instead. So I don’t have the opportunity of wrapping a tag around the form.

So I thought about wrapping the form tag around the whole layout object but this is not working. I’ve created an example here so show what I mean. The files involved are:

  • formtest.php: main page - damn you can’t attach anything without it saying “Not allowed”. Guess I’ll just paste it into this message.
  • saveData.pl: Perl script that is the action of the form - merely dumps out what fields were passed to it
  • formtext.xml: XML data describe the simple form

As it stands this formtest.php produces a simple form with a hidden field and 2 fields and a save button. Filling in the fields and hitting Save works as expected. Three fields are dumped out by saveData.pl, field0, field1 and field2.

Change the “useLayout = true” in formtest.php then you will see no layout at all! Moving the and inside the

displays the form, but there are no fields (other than the hidden one that is explicitly declared in the form.

From what I can tell the form and fields of the dhtmlXForm must occur right after the

and before the .

So then, how do you get data from a dhtmlXForm that is contained in a dhtmlXLayout?

Pasting…

formtest.php:

[code]

Form test html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; }
[/code]

formtest.xml:

<?xml version="1.0"?>
<items>
  <item name="field1"
    type="input"
    position="absolute"
    inputLeft="100"
    inputWidth="100"
    label="field1"
  >
  </item>
  <item name="field2"
    type="input"
    position="absolute"
    inputLeft="100"
    inputWidth="100"
    inputTop="25"
    labelTop="25"
    label="field2"
  >
  </item>

  <item name="save"
    type="button"
    command="save"
    position="absolute"
    inputLeft="50"
    inputTop="50"
    labelTop="50"
    value="Save"
  />
</items>

saveData.pl:

!/usr/bin/perl
use warnings;
use strict;

use CGI qw (:standard :cgi-lib);

print header;
print start_html;
print h2 "saveData.pl";
print p "Parms passed in...";

my %parms = Vars;

foreach (sort keys %parms) {
  print "$_: $parms{$_}<br>";
} # foreach

If you want to post data of dhtmlxForm with html form, “app” div with layout should be inside html form:

Here is sample with data saving:

dhtmlxForm/samples/06_data/03_save.html

That was my initial thought as well. The problem is if I do what you suggest then then I see nothing at all except a blank page! That’s my problem. There is no form, no layout - nothing.

Wait, hold on, the plot thickens… In Chrome (14.0.835.163 beta-m) I see nothing. In FF (6.02) I see nothing. In IE (8.0.6001.18702) I see the form! (Yay!) but entering data and pressing save still shows me that only field0 is read. Field’s 1 and 2 are not passed on to saveData.pl.

Looks like we have some cross browser incompatibilities and a form processing bug still…

As for dhtmlx.com/docs/products/dht … _save.html, this does not apply for 2 reasons. First, I have no problems processing just a dhtmlXForm by itself. I have problems processing a dhtmlXForm that is attached to a dhtmlXLayout. Secondly, I don’t have a data processor.

Or perhaps I just don’t understand this “data processor” thing. From docs.dhtmlx.com/doku.php?id=dhtm … rocessor&s[]=dataprocessor it seems to be related to a dhtmlXGrid - but I have a dhtmlXForm. It also seems to be vaguely tied into (or can be tied into) a “connector”, which seems to be cool for a MySQL backend, for example. However I don’t have a MySQL backend in this case (I have a IBM/Rational Clearquest database to talk to and can only do so through a Perl API).

I’m really just trying to get the fields from this form to a Perl CGI script where I can work my magic from there…

I appreciate your help.

I have attached the working demo.
form.zip (65.5 KB)