Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3699728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:08:18+00:00 2026-05-19T05:08:18+00:00

Consider the following code: echo $this->Form->year(‘expiry’,date(‘Y’),date(‘Y’)+2) This produces output something like: 2013 2012 2011

  • 0

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 or 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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:08:18+00:00Added an answer on May 19, 2026 at 5:08 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following php code used for HTML output: echo <div id='logo2'> <a href='if(checkLanguage())
Consider the following code example: TempList.ForEach(Function(obj) obj.Deleted = True End Function) And this one:
Consider the following code: function Robot(weapon) { this.weapon = weapon; this.fire = function() {
Consider the following code: class myclass { function __construct(&$arg1, &$arg2) { echo $arg1; echo
This is rather interesting, I think. Consider following code, both the window.onload and body
Consider the following code: function authenticate(){ $this->session->set_userdata('logged_in', true); } How do I return this
Consider the following code ( http://jsfiddle.net/FW36F/1/ ): <input type=checkbox onchange=alert(this.checked)> <button onclick=document.getElementsByTagName('input')[0].checked=!document.getElementsByTagName('input')[0].checked;>toggle</button> If you
Consider the following code (you can just put this in the developer console in
Consider the following code snippet: #!/bin/bash #This program tests the if statement in bash.
Consider the following PHP code for printing current date: <!--Date as SEO optimization tool-->

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.