嗨 我想添加一個禁用選項與窗體幫助器的選擇框我使用此代碼來生成一個額外的空字段,但我希望這字段禁用。添加禁用(和選擇)選項與表單助手
echo $this->Form->input('User.usertype_id',array('type'=>'select', 'empty'=>'usertype');
這會產生:
<div class="input select">
<label for="UserUsertypeId">Usertype</label>
<select name="data[User][usertype_id]" id="UserUsertypeId">
<option value="">usertype</option>
<option value="1">athlete</option>
<option value="2">trainer</option>
</select>
</div>
,但我想這一點:
<div class="input select">
<label for="UserUsertypeId">Usertype</label>
<select name="data[User][usertype_id]" id="UserUsertypeId">
<option value="" disabled="disabled" selected="selected">usertype</option>
<option value="1">athlete</option>
<option value="2">trainer</option>
</select>
</div>
有沒有辦法簡單地做到這一點,或者我應該只使用一些JS?
看看我的答案... – Weptunus 2010-11-04 21:56:13
做工精細..謝謝。 – 2016-04-27 11:48:10