Açılır kutu CakePHP oluşturmak için Array manipülasyon

0 Cevap php

this is my problem i,ve to create a dropdown list box from a table states('id','state_name') which is not my default model( which has many fields one of the field is 'state' in which i store states('id') . so i used loadModel to populate the drop down box. in my controller i used

$this->loadModel('State');
$this->set('states',$this->State->find('all'));

görünümü tarafında

$form->select('State_id',$states);

çıkış tablo adı olarak, kimliği ve adı görüntüleniyor.

when i printed $states using pr(); what i got was

Array
(
    [0] => Array
        (
            [State] => Array
                (
                    [id] => 1
                    [state_name] => state1
               )

        )

    [1] => Array
        (
            [State] => Array
                (
                    [id] => 2
                    [state_name] => state2
                )

        )

ve benzeri

how to create an array like array(1=>state1, 2=>state2) from the above array or is there any other way to create a dropdown listbox

lütfen yardım

0 Cevap