Reputation: 19
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>
Upvotes: 0
Views: 46
Reputation: 2361
$this->Form->input('country',array('empty'=>'No country'));
Upvotes: 1
Reputation: 5780
try this...
$this->Form->input('country', array('empty'=>'Select a country'));
Upvotes: 0