Consider the following code: echo $this->Form->year('expiry',date('Y'),date('Y')+2)
This produces output something like:
2013 2012 2011
Now all i want is i dont want to give that empty value in my options list.. Even though the array does not contain any empty elements it still has this option. I've tried specifying the default values. But even though it sets default value it does not remove that empty option tag. For some reason i am checking if that value is empty o开发者_运维技巧r not but still i don't want the user to specify a blank value!!
It would be really great if someone could help me out with this! Thank You!
Take a look at http://book.cakephp.org/view/1413/Form-Element-Specific-Methods#year-1416.
You'll see that the fifth parameter allows you to specify attributes for the field. You need to set the attribute "empty" to false to disable the empty option.
E.g.
echo $this->Form->year('expiry', date('Y'), date('Y') + 2, null, array('empty' => false);
Arron.
精彩评论