By default it appears as though, if I set up a find('list') in the
controller, CakePHP wants to use the ID field in the query regardless
of what I specify (maybe there's an override I don't know about?).
Then when I output that list into the form as a select, it wants to
use the ID field for the value of the select.

The trouble in my case is: I've got a database table filled with zip
codes with their respective cities and states, but I want to get a
list of the states as a drop down for the front end.

// In the controller:
function beforeRender() {
        $states = $this->Location->find('list', array('fields' =>
array('Location.state'), 'group' => array('Location.state')));
        $this->set('states', $states);
}

// In the view:
<?php echo $form->inputs(array( 'legend' => 'Where Are You?',
        'zipcode' => array('type' => 'text'),
        'city',
        'state'));  ?>

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to