Re: Easy way to import Models with their Controllers or vica versa

2009-03-17 Thread Fi

$controller->constructClasses();

worked nicely
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Easy way to import Models with their Controllers or vica versa

2009-03-17 Thread Fi

Hello,

I have an controller with a model and no table and want to access
other controllers and their models from it. This controller doesn't
have any relation to these other controllers. Like so

public function generate()
{
  /* access other controllers and gather data */
}

I tried using uses[] but I only got the models. If I try and import
the controller via App::import I don't get the models with the
controller and it feels a bit wrong.

Is there a nice way to do such a thing?
I want to access from one controller several other controllers methods
which then access their models. Or is it better to just leave the
other controllers alone and focus on the one big controller which uses
several models?

best regards
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



SaveAll() with nested Models

2008-12-28 Thread Fi

Hello,

SaveAll works great with the examples provided in the docs and through
the majority of blogs.
My Problem is that I want to Save three nested Models at once.
Currently I do this with the help of transactions and some awkward
validation.

For example I have these Models:
Test has many Question and Question has many Answer.

If I just want to save the Questions and their related Answers or the
Tests and their related Questions it works like a charm. But when I
want to save all three plus validation it just works on the first two
of them.

View

echo $form->input('Test.name');
[...]
for( $i = 0; $i<2; $i++ )
{
  echo $form->input("Question.{$i}.name");
  [...]
  for( $j = 0; $j < 3; $j++ )
echo $form->input("Answer.{$i}.{$j}.name");
}

Furthermore Cake seems to loose the Form values of the Answer Fields
submitted via POST. It just keeps the last one:
In my Example I have two questions with three answer fields. This
means that the Keys Answer[0] and Answer[1] are already occupied. Cake
now only remembers the the third answer field of every question (e.g.
Answer[0][3] and Answer[1][3]). If I generate three questions Cake
would only remember the fourth answer field.
This problem can be solved If I start $j at the size of the questions
I want to show,
e.g. 3
Answer[0][3], Answer[0][4], Answer[0][5]
Answer[1][3], Answer[1][4], Answer[1][5]
Answer[2][3], Answer[2][4], Answer[2][5]

I hope someone can help me.

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---