我在使用MySQL和存儲過程的第一個字母大寫方面看到了很多帖子。我嘗試了他們,但都沒有爲我工作。下面是我的代碼,我試過..在下拉列表中輸入首字母大寫
PlansController.php
$companies = $this->Plan->Company->find('list', array('conditions' => array('Company.status' => 'active'), 'fields' => array('Company.id','CONCAT(UCASE(LEFT(Company.name, 1)),SUBSTRING(Company.name, 2)) as name'))); //Getting Empty Dropdown
$companies = $this->Plan->Company->find('list', array('conditions' => array('Company.status' => 'active'), 'fields' => array('Company.id', 'UCASE(Company.name)'))); //Getting Empty Dropdown
$companies = $this->Plan->Company->find('list', array('conditions' => array('Company.status' => 'active'), 'fields' => array('Company.id', 'Company.name'))); //Getting Dropdown in view
查看
<select name="data[Plan][company_id]" class="" id="PlanCompanyId">
<option value="">Please Select</option>
<option value="2">xyz abc</option>
<option value="1">lmd abc</option>
<option value="13">Abc ey</option>
<option value="12">sys abc</option>
</select>
期待輸出:
<select name="data[Plan][company_id]" class="" id="PlanCompanyId">
<option value="">Please Select</option>
<option value="2">Xyz Abc</option>
<option value="1">Lmd Abc</option>
<option value="13">Abc Ey</option>
<option value="12">Sys Abc</option>
</select>
如何將下拉的首字母大寫?
使用虛擬字段! http://book.cakephp.org/2.0/en/models/virtual-fields.html – mark