2014-07-02 51 views

回答

0

做一個「龐大」的驗證方法,然後進入驗證本身,檢查是否有「選擇的選項」:如果有一些,檢查「亞狀態」

喜歡的東西

use Symfony\Component\Validator\Constraints as Assert; 
/** 
* 
* @Assert\Callback(methods={"isValid"}) 
*/ 
class ObjectRelatedToYourForm 
{ 
[...] 
    public function isValid(ExecutionContext $context) 
    { 
    if ($this->optionOneSelected) { 
     //perform controls and add violation in case of failure 
    } 
    if ($this->optionTwoSelected) { 
     //perform controls and add violation in case of failure 
    } 
    } 
}