am doing wrong at the moment. Apologies if it is something obvious!
Also I hope I have followed the naming conventions, this could also be
an issue)
I have a belongsTo/hasOne relation set up between page and page_meta
tables. The page_meta table contains a page_id foreign key (and a
primary id key).
When creating a page record, a page_meta record should also be
created, and the data for both records is being passed from a form
(created using the formhelper).
My issue is that the page_meta validation rules don't seem to
functioning correctly. In pagemeta.php I have a classed defined called
PageMeta, in which my array $validate contains:
'limit_per_page' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'Limit per page must not be blank.'
)
),...
There are more validation rules, which don't seem to be functioning
either, but they have been cut for brevity. PageMeta has a $belongsTo
relation with Page (foreignKey => page_id) and Page has a hasOne
relation with PageMeta. (Not all Page's have PageMeta's entries, I
don't think this is related to my problem though.)
The PagesController does "$this->Page->set($this->data);" and then
attempts to validate both models. I have tried 3 different methods of
validation here, and in all cases validation is 'correct' on the Page
data, and doesn't function at all for PageMeta data.
By doesn't function, I mean that $this->Page->PageMeta->validates()
returns 1 even when $this->data['PageMeta']['limit_per_page'] is
empty. $this->Page->saveAll($this->data, array('validate' => 'only')
also returns true when it shouldn't.
If I actually attempt to save (with invalid fields in PageMeta), the
Page data is saved and then the PageMeta query displays a MySQL error
at the top of the page "limit_per_page must be not null" or similar.
I've been playing around with this for a few hours now, and not really
getting anywhere. If both Model's data is correct, the records are
created as expected. Sorry for the extra-long post! Any help would be
greatly appreciated!
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment