I got this simple form with javascript's toolkit dojo into an HTML element form:
dojo.require("dijit.form.Form");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Textarea");
dojo.require("dijit.form.Button");
dojo.addOnLoad(function() {
var form = new dijit.form.Form({
method: "POST",
action: ""
}, "createCollectionForm");
var title = new dijit.form.ValidationTextBox({
required: true,
trim: true
}, "title");
var description = new dijit.form.Textarea({
trim: true
}, "description");
var submit = new dijit.form.Button({
label: "OK",
onClick: function(event) {
dijit.byId("createCollectionForm").submit();
}
}, "submit");
});
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/resources/dojo.css" rel="stylesheet" />
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<body class="claro">
<form method="post" action="" enctype="application/x-www-form-urlencoded" id="createCollectionForm">
<dl class="zend_form">
<dt id="title-label"><label class="required" for="title">Title:</label></dt>
<dd id="title-element">
<input type="text" value="" id="title" name="title" gtbfieldid="1">
</dd>
<dt id="description-label"><label class="optional" for="description">Description:</label></dt>
<dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"></textarea>
</dd>
<dt id="submit-label"> </dt>
<dd id="submit-element">
<input type="submit" value="OK" id="submit" name="submit">
</dd>
</dl>
</form>
But when clicking the submit button, the form is submitting without any post data.
What am I doing wrong?
I think the problem is that your dijit form fields don't have any names. I know you have specified the names in the html code but I think it is necessary to include them in you dijit calls as well, otherwise the submit doesn't know under what names to send the form data.
For Example:
var title = new dijit.form.ValidationTextBox({
required: true,
trim: true,
name: "title"
}, "title");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With