in my Symfony project I would use a new strategy for manage the data form.
I don't want use the Symfony Form object, but I want use the model to build them.
I don't want to redeclare the Base Doctrine_Record class, so I wrote a new Doctrine_Template: ExtendedModel.
In the ExtendeModel template I've new objects and methods, but I need to override the validate() function of Doctrine_Record.
I tried with
class ExtendedModel extends Doctrine_Template {
[...]
public $validatorSchema;
public function setValidatorSchema(sfValidatorSchema $validatorSchema) {
$this->validatorSchema = $validatorSchema;
}
public function getValidatorSchema() {
return $this->validatorSchema;
}
public function validate() {
$this->getInvoker()->setup();
$errorStack = $this->getInvoker()->getErrorStack();
if ($this->getValidatorSchema()) {
try {
$this->getValidatorSchema()->addOption('allow_extra_fields', true);
$this->getValidatorSchema()->clean($this->getInvoker()->toArray(false));
} catch (sfValidatorErrorSchema $errorSchema) {
$errorStack = $this->getInvoker()->getErrorStack();
foreach ($errorSchema->getErrors() as $key => $error) {
/* @var $error sfValidatorError */
$errorStack->add($key, $error->getMessage());
}
}
}
$this->getInvoker()->validate();
}
}
but Doctrine use the original validate() function.
I want to override some Doctrine_Record functions with a new methods declared into my Doctrine_Template.
Could you suggest me a solution for this problem?
Tnx!