Hello,
Another post about my first PHP project. I am sure my question is simple to answer for others, but I haven’t found the answer so far.
I have a class with 8 attributes (ID, name, and 6 integers). So far, I have the following code to retrieve the data from the database, but I understand it tries
$countries = $this->Countries->find();
I want a select using ID as identifier and name as the label. For instance;
<OPTION ID="1">Algeria</OPTION>.
I can’t find detailed documentation about the Form->input function to know how to get my IDs into the ‘value’ attribute of OPTION and the names displayed to the user between the OPTION tags. I managed to create the following code.
<?php echo $this->Form->input('Home country', array('options' => $countries)); ?>
But I see the entire unformatted record ending up in the display, starting with the first option that is automatically assigned value 0. I have seen documentation about HTML but not sure how to apply this here or if that is relevant.
“ID”: 1,
“name”: “Albania”,
“PDI”: 90,
“IDV”: 20,
“MAS”: 80,
“UAI”: 70,
“LTO”: 61,
“IND”: 15
}
Can anyone help?