开发者

Adding an empty option-field in a select-field made by the Model

开发者 https://www.devze.com 2023-04-02 09:57 出处:网络
My model User 开发者_开发问答has a belongsTo relationship with Country. So when I add $this->Form->input(\'country\');

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'));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号