How to set an form error in the action. symfony 1.4
I have a field (company_abn).
I validate this field via web services in the action, so I need to set an error message in the action.
Here is how I did it..
$register_parameters = $request->getParameter('user');
$this->form->bind( $register_parameters );
//do your abn validation stuff
if(!$abn_valid){
//set the value of the 'company_abn' field to invoke the 'required' error message
$register_parameters['company_abn'] = '';
//rebind the form to make it so that, isValid() will = false
$this->form->bind( $register_parameters );
//set your new error message for this widget
$this->form->getValidator('company_abn')->setMessage('required', 'Your ABN is not Valid');
}
very nice =) thanks!