Adding an empty option-field in a select-field made by the Model
My model User 开发者_开发问答has a belongsTo relationship with Country. So when I add
$this->Form->input('country');
in register.ctp for example, a selectfield of countries is shown.
<select name="foo">
<option value="germany">Germany</option>
<option value="finland">Finland</option>
<option value="usa">USA</option>
</select>
So my question is: Is there a cakeway of getting an empty optionfield as first in the selectfield?
Like:
<select name="foo">
<option value="0"></option>
<option value="germany">Germany</option>
<option value="finland">Finland</option>
<option value="usa">USA</option>
</select>
$this->Form->input('country',array('empty'=>'No country'));
try this...
$this->Form->input('country', array('empty'=>'Select a country'));
精彩评论