How can I add label for input other than name or more than name, eg
<label for="category_id">Name - Initial</label>
<开发者_StackOverflow社区input id="category" />
I tried this.
echo $this->Form->input('category_id', array('multiple'=>'checkbox','label' => 'Category.initials'));
This is what I want to achieve.
<label for="category_id">Name - Initial</label>
<input id="category" />
ANSWER FROM GOOGLE!
You can create a virtual field[1] in the model.
public $virtualFields = array(
'full_name' => 'CONCAT(User.last_name, ", ", User.first_name)'
);
Then, I believe (haven't tried this) that you could specify full_name as the model's display field:
public $displayField = 'full_name';
As far as I understand it you can set the label to anything you want by passing it a string:
array( 'label' => 'Name - Initial');
Or you could build that string out of some pre-existing variables:
array( 'label' => $name . ' . ' . $initial);
Or have I misunderstood what you're trying to do?
精彩评论