2011-08-20 31 views

回答

3

據我所知,沒有。

但是你可以在你的表單中這樣做。手動在表單類中,擴展isValid方法以檢查至少checkbox_1或checkbox_2是否爲票證。你應該做阿德里安所說的使用無線電。但原則是一樣的。

<?php 

class App_Your_Form extends Zend_Form 
{ 
    public function init() 
    { 
     ... Your stuff ... 
    } 

    public function isValid($data) 
    { 
     $isValid = parent::isValid($data); 

     if ($this->getValue('checkbox_1') != '1' && $this->getValue('checkbox_2') != '1') { 
      $this->getElement('checkbox_1')->setErrors(array('You have to set check at least chexbkox_1 or checkbox 2')); 
      $isValid = false; 
     } 

     return $isValid; 
    } 
} 
3

如果您使用無線電元件,您只需要setRequired(true)。 Zend元素實際上適用於MultiCheckbox

$element->setRequired(true);