I can't answer your question about HABTM/saveAll() but what I've done
in the past is put the validation rule in the 'JoinModel'. In the
controller for the other model:
$this->SavingModel->JoinModel->set($this->data);
if (!$this->SavingModel->JoinModel->validates())
{
$this->SavingModel->JoinModel->invalidate('JoinModel');
}
else if ($this->SavingModel->save($this->data))
{
...
I do think it's worth filing a bug about what you described, fwiw.
That does seem odd. But I haven't had the best luck with that, either.
The last time, I received the usual sarcastic replies that suggested
I'm clueless. However, although never acknowledged, the bug I reported
was fixed :-)
On Wed, Oct 7, 2009 at 2:15 AM, WebbedIT <[email protected]> wrote:
>
> I will belatedly add my weight to this topic and maybe we can come up
> with a bug to be ticketed with examples between us.
>
> @mcrawford: I believe you are trying to apply the validate rule to the
> wrong model as the fields for the join table do not exist in your
> Question model, hence it will never try to validate them.
>
> What I have done in the past is add the rules to the join model within
> the beforeFilter() of the model I am saving the data from.
>
> function beforeFilter() {
> parent::beforeFilter();
> $this->SavingModel->JoinModel->validate = array(
> 'JoinModel' => array(
> 'rule' => array('multiple', array('min'=>1)),
> 'message' => 'Select one or more options'
> )
> );
> }
>
> However saveAll's validate logic does not seem to check for habtm
> validate rules as I have mentioned in an earlier post
>
> http://groups.google.com/group/cake-php/browse_thread/thread/3390943040e2ded9/5db36a67bbcedae7
>
> This unfortunately got hijacked from people telling me to learn how to
> use 'multiple rules' even though I kept telling them I was after
> information on using the 'core multiple rule' (the title of the topic
> even gave the correct cookbook page - DOH!).
>
> I assume no-one from the dev team looked at that topic as I kept
> asking someone with more knowledge to try and shed some light but no-
> one did.
>
> The hack I used to resolve the issue is in the above topic and after
> recently upgrading to 1.2.5 stable I can see this hack is still needed
> so I think we'll have to make Cake aware of this ... otherwise how
> will they ever be able to resolve it.
>
> I have never opened a ticket before and see a lot of them get knocked
> back due to poor test cases and stuff, anyone reading this got
> experience of raising good tickets or know of a guide which would
> advise me on how to do it?
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---