我的代码如下:
Zend表格:
$explicit = new Zend_Form_Element_Checkbox('explicit');
$explicit->setLabel('Explicit?');
$explicit->setAttribs(array('id'=>'explicit'));
$explicit->setCheckedValue(1);
$explicit->setUncheckedValue(0);
Zend观点:
<?php echo $this->{$this->element->explicit->helper}($this->element->explicit->getName(), $this->element->explicit->getValue(), $this->element->explicit->getAttribs());?>
Zend Controller:
选中:
$explicit = $this->getRequest()->getPost('explicit');
和:
$formSongs->explicit->isChecked()
$ checked每次都返回0并且isChecked总是假的......我是否从视图助手中省略了什么?还是一个不同的问题?
泰
答案 0 :(得分:0)
在您的Zend表格中,您可以这样做: -
$explicit = new Zend_Form_Element_Checkbox('explicit ','explicit',
array('checkedValue' => 1,
'uncheckedValue' => 0,)
);
$explicit -> setLabel('Explicit?');
-> setValue(1); //set default value to one.