Component problem.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Component problem.

Bernard Grosperrin

Ok, I have made couple of components working well, but this one give me
a error all the time, and I am unable to see what's wrong:


    class StockRequestComponent extends Object
    {
       var $controller = true;
       // I have to find a way to have a function here which can receive
parameters(or not)
       // and would find only the locations for the current user
 
      function startup (&$controller)
       {
           $this->controller = &$controller;
           $Product = new Product;
           $data = $Product->findAll();
           
$this->controller->set('StockRequest',$data);                                

       }              
    }

The view is:

<div id="user_status">


    <?php    
if ($this->controller->name == 'Stocks')
{
echo '<form>';
echo '<select
OnChange="product.href=this.options[this.selectedIndex].value">';
echo '<option value="http://cake.bgsoftfactory.com/stocks/index/1/0">--
Select a Section --';
foreach ($StockRequest as $output):
echo '<option value="http://cake.bgsoftfactory.com/stocks/index/1/' .
$output['Product']['description'] . '">' .
$output['Product']['description'];
endforeach;
echo '</select>';
echo '</form>';
}
  ?>
</div>

the error is: " Undefined variable: StockRequest in.."....etc

A very similar component, on a different table, works just fine. Thanks
for your help,

Bernard


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Component problem.

Zach Cox

Maybe startup is not the best method to set a controller variable in.
Are you sure startup is even being called?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [professionel] Re: Component problem.

Bernard Grosperrin

[hidden email] wrote:
> Maybe startup is not the best method to set a controller variable in.
> Are you sure startup is even being called?
>  
I would not get an error if it was not called.

Bernard


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Component problem.

Meek-2


Bernard Grosperrin wrote:
> [hidden email] wrote:
> > Maybe startup is not the best method to set a controller variable in.
> > Are you sure startup is even being called?
> >
> I would not get an error if it was not called.
>
> Bernard

Yes you would - you don't need to call a function to 'create' an
'Undefined variable' - the previous poster was correct - the first
thing you should do is make sure that the startup function is being
called.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: [professionel] Re: Component problem.

Bernard Grosperrin

meek
>
> Yes you would - you don't need to call a function to 'create' an
> 'Undefined variable' - the previous poster was correct - the first
> thing you should do is make sure that the startup function is being
> called.
>
>  
I realized that after my post. Thanks for your help,
Bernard


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---