First thing you might want to do is take the set function call out of
the if(empty()) conditional you have. The reason is because you want
this variable set every time, regardless of the state of $this->data,
to keep the select options properly populated. The way you have it
now, you will lose your select options in the event that you have to
resubmit the form due to errors, etc, because then the $this->data
array is set.
Second, you can force the input field to become a select by using the
select() function. Try switching your input function with that.
$form->select('finished_product_id', $finished_products, null,
array());
or
$form->input('finished_product_id', array('options' =>
$finished_products));
Hope that helps.
On May 11, 2:25 pm, Stefano Martins <[email protected]> wrote:
> Hey folks,
>
> I have two controllers: ConfigurationsController and
> FinishedProductsController. Here's the code for the
> ConfigurationsController:
>
> <?php
> class ConfigurationsController extends AppController
> {
> public function add()
> {
> if(empty($this->data))
> {
> $this->set('finished_products',
> $this->Configuration->FinishedProduct->find('list'));
>
> }
> }
> }
> ?>
>
> In the view, the select is showing up right, but its not populated
> with the finished products. Here's the code for the view:
>
> <?php
> echo $form->create('Configuration');
> echo $form->input('finished_product_id');
> echo $form->input('ammount_of_items');
> echo $form->end('Próximo passo');
> ?>
>
> Can someone help me out?
>
> Thanks!
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en