パスワード用のフィールドを作成する次のコードがあります。
// Element: password
$this->addElement('Password', 'password', array(
'label' => 'Password',
'description' => 'Passwords must be at least 6 characters long.',
'required' => true,
'allowEmpty' => false,
validators' => array(
array('NotEmpty', true),
array('StringLength', false, array(6, 32)),
)
));
$this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND'));
$this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty');
私のコントローラーでは、いくつかの条件に応じて、バリデーターを削除し、コントローラーから「必須」を false にする必要があります。
例えば:-
if($someCondition){
//Set required to false and remove validator here somehow
}
この場合の解決策を知っている人はいますか?