Wednesday, July 1, 2009

Re: Validating associated models fields - cannot get it working.

OK, so the minute I posted this, I noticed that actually the field
names are OK, but the messages are not displaying for those fields.

Output of <?php pr($this->validationErrors); ?> :

Array
(
[Post] => Array
(
[name] => The name for your tip should be at least 10
characters.
[Tag.name] => 10 chars please.
)

)

The "name" field error is displayed, but the "Tag.name" fields error
isn't...

On Jul 1, 11:09 am, number9 <xpozit...@gmail.com> wrote:
> I have a form where users can add tags/images at the same time as
> adding a post.
>
> These fields are referenced like this in the view:
>
> echo $form->input('Img.pic')
> echo $form->input('Tag.name')
>
> I am trying to add validation rules to these fields in the post model,
> referencing the fields as follows:
>
>         'Img.pic' => array(
>                         // rules etc. go here
>                 )
>
>         'Tag.name' => array(
>                         // rules etc. go here
>                 )
>
> I have also tried adding validation rules to the Tag model (no Img
> model exists because it is a component).
>
> How should I be doing this? I have searched but cannot find a
> solution. I have tried various validation rules and the rest of the
> models validation rules are working fine.
>
> Would appreciate any suggestions!
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: