• 13th July 2010 - By admin

    Been struggling with something lately – and that is to get the select boxes on the edit / add views of a cakePHP app to show the correct thing.

    For instance I have a Countries table that has an association to the UserAddress model, to get this association and pull out the country name rather than the coutnry_id I have to do the following:

    $countries = $this->UserAddress->Country->find('list', array('fields' => array('Country.country')));

    Sometimes CakePHP automagic takes away a bit of common sense from us :)

    Share with your friends and help out this site:
    • Digg
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • E-mail this story to a friend!
    • LinkedIn
    • Live
    • Reddit
    • StumbleUpon
    • Twitter
    • Yahoo! Bookmarks

Ad