Let's say I have in my controller:
$this->set('locations', $this->Location->find('list', array('fields' => array('state')) ));
How do I get my view to generate a form select with options:
<select name="data[Location][state]" class="inputbox" id="Location">
<option value="Arizona">Arizona</option>
<option value="California">California</option>
<option value="Hawaii">Hawaii</option>
</select>
Because it is generating:
<select name="data[Location][state]" class="inputbox" id="Location">
<option value="1">Arizona</option>
<option value="2">California</option>
<option value="3">Hawaii</option>
</select>
I'm aware that cakephp uses primary key by default for the values and there's an answered question but the solution did not work for me: how do you create a select with both value and the label the same from an array in cakephp?
In my view, I have:
<?php echo $form->select('Location.state', $locations); ?>
My database is: locations
id | state
1 | Arizona
2 | California
3 | Hawaii
and so on