Input listing query result cakephp

1
Hello, I am trying to list a result of a query from my controller in an input, but it is returning zero, but when I give print_r , it returns the whole array, what's wrong?

Controller:

public function add() {
    if ($this->request->is('post')) {
        if ($this->Foto->save($this->request->data)) {
            $this->Session->setFlash('Recipe Saved!');
            $this->render('add');
        }
    }
    $acomodacoes = $this->Navigation->find('list');
    $this->set('acomodacoes',$acomodacoes);
    print_r($acomodacoes); // estou dando esse print_r só para ver se realmente existe um array
}

My form:

<?= $this->Form->create('Galeria.Foto',array('type' => 'file')); ?>
<fieldset>            
    <legend><?= __('Adicionar Galeria de fotos'); ?></legend>
     <strong> Hot? </strong>
    <?=  $this->Form->checkbox('hot', array('value' => 1)); ?>
    <?=  $this->Form->input('acomodacoes',array('class' => 'form-control')); ?>
    <?=  $this->Form->input('titulo',array('class' => 'form-control')); ?>
    <?=  $this->Form->input('descricao',array('class' => 'form-control')); ?>                
    <?=  $this->Form->input('Imagem', array('type' => 'file')); ?>

</fieldset>
<?php echo $this->Form->end(__('Submit',array('class' => 'form-control'))); ?>
    
asked by anonymous 17.04.2015 / 19:45

1 answer

1

You need to enter the array $ accomodations in the related input . And being several options, you need the properties type and options :

$this->Form->input('acomodacoes', array(
    'class' => 'form-control',
    'type' => 'select',
    'options' => $acomodacoes)
);

For options, you will have the id of the item as the%, and if your Model has set value , this text will be displayed.

    
17.04.2015 / 19:58