Reputation: 2503
Lets suppose I have a user registration form. Since the password must be stored md5 encoded, the best idea would be to convert it in redhand, but it looks request
is read only. How to change a form field during processing?
Upvotes: 0
Views: 293
Reputation: 1135
You can use a custom Validator for the form. Create a class like this:
<?php
class encodeValidator extends sfValidatorBase
{
/**
* @see sfValidatorBase
*/
protected function doClean($value)
{
return md5($value); //md5 can be replaced with another encoding method
}
}
Next, when you create your form, add the custom validator you created, like this:
$this->setWidget('field_name', new sfWidgetFormInputText());
$this->validatorSchema['field_name'] = new encodeValidator();
Upvotes: 1