Re: Undefined variable in view
You have to understand that the Pages controller is special! The Pages
controller uses the display method to show your "showscore" view,
which means that your "showscore" method in the Pages controller will
never be invoked.
You can see why the Pages controller uses the display method, as that
is the default route defined for the Pages controller in the CakePHP
book at:
http://book.cakephp.org/#Defining-Routes-948
So you have to move your method into another controller or make
another solution.
Enjoy,
John
On Feb 21, 5:13 pm, Slim <omars...@gmail.com> wrote:
> Hello everybody,
>
> I'm using the default cakephp controller (pagesController)
>
> I created some form (form->create(null);) because it's not related to
> a specific model.
>
> When i try accessing the data sent via the form when 'index' action is
> called everything is OK;
>
> I put then on my index.ctp
> "
> <?php echo $this->Form->create(null,array('action' => 'showscore'));
> //or even
> echo $this->Form->create('Pages',array('action' => 'showscore'));
> ?>
> "
> I created the view showscore.ctp which content is:
> "
> <?php
> echo "Your basic score is : ".$myscore;
> ?>
> "
>
> in pagescontroller, in the action showmyscore i have : (I know i'm
> still not using data from form here
> "
> //print_r($this->data);
> App::import('Lib', 'CalculateScore');
> $score=new CalculateScore();
> $this->set('myscore',$score);
> "
>
> When I run all this i get this error :
>
> Notice (8): Undefined variable: myscore [APP\views\pages
> \showscore.ctp, line 2]
>
> any help please ?
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home