# |
Aug 9th 2008, 17:45 |
jaredhoyt |
yeah, try http://bin.cakephp.org/view/1303690479 |
# |
Aug 9th 2008, 17:43 |
jezek |
nope |
# |
Aug 9th 2008, 17:43 |
jaredhoyt |
are you defining the variable outside of startup() as well? like $userInstance = null; or whatever |
# |
Aug 9th 2008, 17:42 |
jezek |
ok |
# |
Aug 9th 2008, 17:41 |
jaredhoyt |
or whatever model it is |
# |
Aug 9th 2008, 17:41 |
jezek |
the name of the variable? |
# |
Aug 9th 2008, 17:41 |
jaredhoyt |
don't know if it loads it automatically into the class with the same name... try $this->userInstance = ... |
# |
Aug 9th 2008, 17:41 |
jaredhoyt |
maybe try changing the name... i'm not 100% how init() works... |
# |
Aug 9th 2008, 17:41 |
jezek |
yeah it works fine that way |
# |
Aug 9th 2008, 17:40 |
jaredhoyt |
like it is in the manual |
# |
Aug 9th 2008, 17:39 |
jaredhoyt |
jezek: did you try just instantiating the model in the method first? |
# |
Aug 9th 2008, 17:39 |
JD__ |
so it looks llke i need to make a new profile object, load the data, run validation, then resave everything else |
# |
Aug 9th 2008, 17:39 |
JD__ |
Im dying there because i have model validation in my profile object.. the save silently fails |
# |
Aug 9th 2008, 17:39 |
jaredhoyt |
hmmm |
# |
Aug 9th 2008, 17:38 |
jezek |
http://bin.cakephp.org/view/1303690479 |
# |
Aug 9th 2008, 17:38 |
jaredhoyt |
JD__: have you tried http://book.cakephp.org/view/66/models#saving-related-model-data-haso-84 |
# |
Aug 9th 2008, 17:37 |
jezek |
"Call to a member function findById() on a non-object i" |
# |
Aug 9th 2008, 17:37 |
jezek |
i'll try that |
# |
Aug 9th 2008, 17:37 |
JD__ |
Is there a book.cakephp.org articale or bakery article regarding saving models recursivley? I have a user object with a profile memebr object, and it seems pretty crazy making two objects , running the validation, and saving. I have a big mess now that doesn't work, I have been looking for some docs on it but have have come up empty |
# |
Aug 9th 2008, 17:37 |
jaredhoyt |
$this->User = ClassReg... |
# |
Aug 9th 2008, 17:36 |
jaredhoyt |
just have to set it to a class var instead of function var |
# |
Aug 9th 2008, 17:36 |
jaredhoyt |
no, you could do it in the startup() or initialize() |
# |
Aug 9th 2008, 17:36 |
jezek |
do i have to put $userInstance = ClassRegistry::init('User'); within every function? |
# |
Aug 9th 2008, 17:36 |
jezek |
yeah |
# |
Aug 9th 2008, 17:35 |
jaredhoyt |
jezek: have you read the last section of this : http://book.cakephp.org/view/62/components#mvc-class-access-within-components-65 |
# |
Aug 9th 2008, 17:34 |
jezek |
i'd rather not have to |
# |
Aug 9th 2008, 17:34 |
jezek |
he just asked that |
# |
Aug 9th 2008, 17:34 |
jezek |
no |
# |
Aug 9th 2008, 17:34 |
jaredhoyt |
jezek: are you trying to access a model that is included in the $uses of the component's calling controller? |
# |
Aug 9th 2008, 17:34 |
jezek |
i guess i could |
# |
Aug 9th 2008, 17:34 |
jezek |
no |
# |
Aug 9th 2008, 17:33 |
jaredhoyt |
np |
# |
Aug 9th 2008, 17:32 |
primeminister_ |
jaredhoyt: thnx! |
# |
Aug 9th 2008, 17:32 |
Matt1 |
jezek: you are calling it from a controller, right ? |
# |
Aug 9th 2008, 17:32 |
jaredhoyt |
right |
# |
Aug 9th 2008, 17:32 |
primeminister_ |
jaredhoyt: and then do a save without validation |
# |
Aug 9th 2008, 17:32 |
primeminister_ |
jaredhoyt: ah of course |
# |
Aug 9th 2008, 17:31 |
jezek |
so i have to load the model somewhere else? |
# |
Aug 9th 2008, 17:31 |
jaredhoyt |
if you're validating both models at the same time, it would just be something like $this->Modelx->set($this->data); $this->Modely->set($this->data); if($this->Modelx->validates() andand $this->Modely->validates()) { } |
# |
Aug 9th 2008, 17:31 |
primeminister_ |
jaredhoyt: yeah |
# |
Aug 9th 2008, 17:31 |
jaredhoyt |
primeminister: you're going to have to validate Modely the same way you do Modelx |