views:

105

answers:

1

I am trying to get started with PEAR's HTML_QuickForm but I'm having a problem. For some reason all of my form data is being submitted with GET and not POST. The default is supposed to be POST and I've tried setting it explicitly. The only thing I've been able to figure out is that when I simply call display() on the form it works correctly. I'm using a static template and for some reason when I use that it doesn't work correctly. My code is presented below.

<?php
include_once 'HTML/QuickForm.php';
include_once 'HTML/Template/Sigma.php';
include_once 'HTML/QuickForm/Renderer/ITStatic.php';

$form = new HTML_QuickForm('formtest', 'post');
$form->addElement('text', 'mytext');
$form->addRule('mytext', 'This is required', 'required');
$form->addElement('submit', 'mysubmit', 'This is a submit button');

$tpl = & new HTML_Template_Sigma('.');
$tpl->loadTemplateFile('template.html');
$renderer = & new HTML_QuickForm_Renderer_ITStatic($tpl);
$renderer->setRequiredTemplate('{label}<font color="red" size="1">*</font>');
$renderer->setErrorTemplate('<font color="red">{error}</font><br />{html}');
$form->accept($renderer);
$tpl->show();
?>
+1  A: 

Nevermind, I am an idiot and almost immediately realized the problem. My template file looked like this:

<html>
<head><title>Test Form</title></head>
<body>
<form>
{formtest_mytext_html}<br />
{formtest_mytext_label}<br />
{formtest_mysubmit_html}<br />
{formtest_mysubmit_label}<br />
</form>
</body>
</html>

The problem was that my form tag had no way to know that it was supposed to be POST so it always defaulted to GET. Instead the form tag should have looked like this

<form {formtest_attributes}>

The {formtest_attributes} of course being the bit that tells the form to make itself POST.

Jonathan