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

  • SEARCH
  • Home
  • 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 1115897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:13:27+00:00 2026-05-17T03:13:27+00:00

Heres my code: //Setup days $data[‘days’][‘FALSE’] = ‘Day’; //Setup months $data[‘months’] = array(‘FALSE’ =>

  • 0

Heres my code:

//Setup days
 $data['days']['FALSE'] = 'Day';

 //Setup months
 $data['months'] = array('FALSE' => 'Month',
                 '1'  => 'Jan',
                 '2'  => 'Feb',
                 '3'  => 'Mar',
                 '4'  => 'Apr',
                 '5'  => 'May',
                 '6'  => 'Jun',
                 '7'  => 'Jul',
                 '8'  => 'Aug',
                 '9'  => 'Sep',
                 '10' => 'Oct',
                 '11' => 'Nov',
                 '12' => 'Dec'
                );


 for($i=1;$i<=31;$i++){
    $data['days'][$i] = $i;
 }

 //Setup years
 $start_year = date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")-100)); //Adjust 100 to however many year back you want
 $data['years']['FALSE'] = 'Year';

 for ($i=$start_year;$i<=date("Y");++$i) {
    $data['years'][$i] = $i;
}

and here’s my if statement:

if($this->form_validation->run()){
    $month = $this->input->post('months');
    $day = $this->input->post('days');
    $year = $this->input->post('years');

    $birthday = date("m-d-Y H:i:s",mktime(0,0,0,$month,$day,$year));
 } 

here’s my corresponding code in my form in the view:

   <p>
        <label for="birthday">Birthday: </label>
        <?php echo form_dropdown('days',$days). " " . form_dropdown('months',$months). " " . form_dropdown('years',$years); ?>
    </p>

When I put the datepicker code directly in my controller the drop down on my form shows correctly. I wanted to be neat with my coding so decided to create a model and attempted to make calls from my controller but I get the undefined variable error a few times when my view tries to display the form.

I’ve done some research and wondering whether it’s better to make my datepicker a helper “datepicker_helper.php” put the code in there and load it in my controller.

Is this the best way to do this?

If so can somebody give me a example of how I can do this? If there is another way can somebody show me please?

Thanks in advance.. I’m here to learn..

  • 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-17T03:13:28+00:00Added an answer on May 17, 2026 at 3:13 am

    A lot of developers – myself included – have developed their own version of this code. There are two issues I want to point out here.

    First of all, you’ve lulled yourself into a false sense of security here. Bounded select elements can not and will not guarantee that every request includes a valid date. Never trust input. Always validate. Extend the Form_validation class with your own date validation functions.

    Second, making a user pull three dropdowns (without the mitigating guarantee of a valid date in all requests) is pretty crappy UX, especially in cases where the user needs to populate multiple dates (start date/end date, milestone dates, etc).

    After I came to understand these two things, I refactored this out of my site. Now my date fields are input type text, with a label that specifies the expected format of the date. My Form_validation class is extended to validate date fields. And I’ve added a real datepicker to my forms.

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

Sidebar

Related Questions

Here is my code: class MyTestCase(Base): def setUp(self): #some code here def test_B(self): #some
Here is my code #!usr/bin/env perl # Setup includes use strict; use XML::RSS; use
im trying to use direct store in Extjs heres the code to my store
unforunately i cant reproduce it in jsfiddle...... heres my code though regardless: http://jsfiddle.net/nZePr/ basically
I want to get a url from a string. Heres my code to extract
I'm stuck on how to use the 'text-overflow' function. Heres my code: <style type=text/css>
I've been playing around with Inno Setup for a couple days now, and have
I have several methods that execute the same setup code and then some cleanup
I'm working on some old AJAX code, written in the dark dark days before
I tried to set up my togglebutton properties layout using style.xml. Here's my code:

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.