Symfony DoctrineChoince Validator 'Where' condition
I want to make a "forgot password" form. For the username
field I used the code:
$this->form->setValidators(array(
'username' => new sfValidatorAnd(
array(
new sfValidatorString(array('min_length' => 4),
array(
'min_length' => 'Minim %min_length% caractere.',)),
new sfValidatorDoctrineChoice(array(
'model'=>'Users',
'column'=>'username'), array(
'invalid' => 'Utilizatorul nu există.',
)),
),
array(),
arra开发者_开发技巧y(
'required' => 'Câmp obligatoriu',
)
),
but for the email
field I want to use the sfValidatorDoctrineChoice
with a custom query, where the WHERE
condition is: username = the 'username' field value gathered from the form.
What variable contains this value?
$this->form->getValue('username')
$request->getParameter('FormName')
then the array contains all the submitted data.
$this->form->getValue('username')
works only for bound and validated data.
精彩评论