开发者

validation issue with zend checkbox

开发者 https://www.devze.com 2023-03-25 19:03 出处:网络
everyone, I have create a zend form have a checkbox for license agreement. I want to s开发者_JAVA技巧how an error message when a user submit the form with out checking the agreement check box.

everyone, I have create a zend form have a checkbox for license agreement. I want to s开发者_JAVA技巧how an error message when a user submit the form with out checking the agreement check box.

Thanks Anurodh


There is a bug in zend_framework with the required checkbox. But you can do something like this.

$this->addElement(
      'checkbox', 'checbkox_name', array(
            'required' => true,
            'uncheckedValue' => null
        )
    );

edit for readability

$acceptAggrement = new Zend_Form_Element_Checkbox('accept_aggrement');
$acceptAggrement->setLabel("Accept Aggrement :");
$acceptAggrement->setUncheckedValue(null);
$acceptAggrement->setRequired(true); 
0

精彩评论

暂无评论...
验证码 换一张
取 消