Cakephp 2.3: How to not use 'id' as the label of $belongsTo <select> options

前端 未结 1 865
攒了一身酷
攒了一身酷 2020-12-22 06:03

I run into this dilemma a lot with Cakephp, and I\'m prettty sure it\'s a consequence of my not following/understanding a convention somewhere. In any kind of belongsT

相关标签:
1条回答
  • 2020-12-22 06:21

    For single column tables, a simple $displayField = 'column_name' is the answer.

    But for concatenations of columns, there's a bit more code involved:

    public $virtualFields = array("full_name"=>"CONCAT(first_name, ' ' ,last_name)");
    public $displayField = 'full_name';
    

    If its a really complicated $displayField, an afterFind solution may be necessary, but for most cases this is the solution.

    Hope that helps.

    0 讨论(0)
提交回复
热议问题