Tag Archives: Display Field instead of ID

CakePHP 2 – Tip#1: Display Field instead of ID

Display Field instead of ID:

Whenever CakePHP automagically fetches lists from your tables, it uses the id key for the value and the $displayField for the text.

If your table has a name or title field, CakePHP automatically displays it as the display field. So, either rename the field that you want as your display field (say, candidate_name to just name) or set the $displayField variable in your model:

class Candidate extends AppModel {
    var $displayField = 'candidate_name';
}

Source:
http://stackoverflow.com/questions/4558505/cakephp-related-tables-show-ids-instead-of-values

Manual: