Hi there,
there is a bug with the Zend_Form_Element_Checkbox, when i added a Checkbox
element, with the checkValue 1 and unCheckedValue 0, to the form, and then
render it with this banner,$this->form->checkElement->renderViewHelper(),
then post the form with the checkElement unchecked to the same page that
with the form , and then view the page source, the checkedValue and
unCheckedValue of checkElement would be the same, with value 0.
sorry for my poor english.do anyone understand me? or just try following:
TestController.php
<?php
class TestController extends Zend_Controller_Action
{
public function indexAction()
{
$form = new Zend_Form();
$checkElement = new Zend_Form_Element_Checkbox('checkElement');
$checkElement->setUncheckedValue(0);
$checkElement->setCheckedValue(1);
$checkElement->setValue(1);
$form->addElement($checkElement);
$this->view->form = $form;
}
}
views/scripts/test/index.phtml
<html>
<head>
<title>template for the test controller index action</title>
</head>
<body>
<form method="post">
checkElement:<?php echo $this->form->checkElement->renderViewHelper(); ?>
<input type="submit" value="post the form" />
<p>leave the checkElement unchecked,then post this form,then search the
value for the <input type="checkbox" name="checkElement" /> in the the page
source,and see what?</p>
</form>
</body>
</html>
Best Regards,
Jacky