I have in my database a table Test with the following fields :
id | name
1 | YW55IGNhcm5hbCBwbGVhcw==
2 | fghfghgcm5hbCBwbGVhcw==
Name is hashed using base64. In my model I can overwrite this method:
public function getName() {
return base64_decode($this->getName);
}
and in function save:
$this->setName(base64_encode($this->getName));
this is working OK, but i have big problem with filter in admin generator. If i type for filter name exist NAME, for example “stackoverflow” then this make query with “stackoverflow” instead of base64_encode(‘stackoverflow’). Is possible overwrite this? If yes, how?
I use Symfony 1.4 and Doctrine.
Overload
doBuildQueryin thesfFormFilterDoctrinesubclass for that field, such that it queries by the encoded value.http://trac.symfony-project.org/browser/branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php#L148
EDIT: alternately, you could overload
addTextQuery. Either way, explain the business logic clearly in a comment