i solved doing the next
$this->User->data = $this->data;
$UserValid = $this->User->validates();
this should validates the User fields and if there are some of them wrong,
cake reconize them and invoque the tagErrorMsg
$this->User->Profile->data = $this->data;
$ProfileValid = $this->User->Profile->validates();
make the same with the Profile
then you should
if ($ProfileValid && $UserValid) then -> save both of them
this worked for me
Dr. Tarique Sani wrote:
>
>
> Ran into this seemingly simple problem which I have not been able to solve
> :(
>
> I have User model which hasOne Profile model
>
> The users/add view has fields for both User and Profile with
> corresponding tagErrorMsg like
> $html->tagErrorMsg("Users/username") and
> $html->tagErrorMsg("Profile/fullname") etc
>
> In the users_controller - add action - I do
>
> $user_validates = $this->User->validates();
>
> $profile_validates = $this->User->Profile->validates();
>
> Subsequently I test if both are true and do the needful to save both
> models. (setting user_id in profile after saving user and the works)
>
> - If the all data is valid saving works.
> - If the User data is not valid I see error messages rendered via
> tagErrorMsg
> - BUT if Profile data is not valid no error messages are rendered.
>
> What would be the simplest way to solve this?
>
> In other words how to get tagErrorMsg to render validationErrors from
> an associated hasOne model with minimal coding and what would be the
> correct cakePHP way to do it.
>
> Thanks in advance
>
> Tarique
>
> --
> =============================================================
> PHP for E-Biz: http://sanisoft.com
> Cheesecake-Photoblog: http://cheesecake-photoblog.org
> =============================================================
>
> >
>
--
View this message in context:
http://www.nabble.com/hasOne-association%2C-Form-and-tagErrorMsg-tp8557744p15133510.html
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---