anybody an idea, how i can validate them both togehter? whatever i try, it seems to validate only one at a time
On 17 Feb., 15:56, "Mark (Germany)" <dereurom...@googlemail.com> wrote: > hey there > > i tried for hours - but i can't get it to work > i want that the errors of the model AND of the behaviour are both > shown togehter (not after each other, as soon as one of them is fine). > > i tried it with before/afterValidate, etc, with returning queryData > and return false... all kind of possibities > > MODEL: > > function beforeSave() { > if > (!empty($this->data['RelationRequest']['new_request'])) { > if > ($this->requestExists($this->data['RelationRequest'] > ['user_id'], UID)) { > $this->invalidate('user_id','a > request is already pending - > please be patient'); > return false; > } elseif ($this->User->Relation->hasRelation > (RELATION_STATUS_BLOCKED, $this->data['RelationRequest']['user_id'], > UID)) { > $this->invalidate('user_id','you have > been blocked'); > return false; > } elseif ($this->User->Relation->hasRelation > (RELATION_STATUS_FRIENDS, $this->data['RelationRequest']['user_id'], > UID)) { > $this->invalidate('user_id','you are > already friends'); > return false; > } > } > return true; > } > > BEHAVIOUR: > > public function beforeSave(&$model, &$queryData) { > $this->model = $model; > > if > (!$this->validateCaptcha($this->model->data[$this->model->name])) > { > > $this->model->invalidate('captcha','captchaResultIncorrect'); > return false; > } > unset($this->model->data[$this->model->name]['captcha']); > unset($this->model->data[$this->model->name]['captcha_hash']); > unset($this->model->data[$this->model->name]['captcha_time']); > } > > what am i missing here? > i know that the behaviour gets triggered first - and if i return false > here, the validating of the model is skipped > if i do not return false, the form will submit successfully, even it > the captcha invalidates.. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---