Hi
I need to check that the answer I’m inserting into the database for a specific question only has one of it’s answers labelled correct (correct=1). To that end I’m trying to intercept the save before it’s committed and make sure the correct count of answers for the question is not greater than 0. If it is I want to raise an error and not save the record.
I tried overriding the beforesave method but nothing seemed to be happening. Even if I just took everything out of the function and returned false it would still save the record.
My latest test looks like this…
public function beforeSave() {
if ($this->isNewRecord)
$this->answer = 'fred';
$this->answer = 'fred';
return parent::beforeSave();
}
Trying to change the answer text to ‘fred’ but it doesn’t have any affect which leads me to think it’s not firing.
Any suggestions would be greatly welcome.
Regards
Steve