6 Replies Latest reply on Aug 15, 2013 1:51 PM by konatham

    Auto-load current date ?

    lsdean

      Hi Robert,

       

      Is there a way to auto-load the current date to a date field and bypass the date picker?

       

      Below is a snippet of a field definition, and it works great, but what it is really needed is way to auto-load the current date (mm/dd/yyyy).

       

      {

         "id": "dateposted",

         "label": "Date Posted",

         "type": "date",

         "values": "",

         "value": "",

         "title": "",

         "required": true,

         "patterns": "",

         "patternError": ""

      },

       

      Below is a screen shot of the form being completed. The Date Posted will always be the date the form is filled, the Ad Valid Until will always need the date picker.

       

       

       

      Any suggestions?

        • Re: Auto-load current date ?

          Unfortunately the setting of a default date isn't currently available.  However, it was a very minor change to be able to support that feature.  This is currently being tested in the Jive sandbox and will be pushed out with the next update to the app.

           

          The format of the template will not change, once the update is out all you have to do is set a "value" (which is the default value) on the datepicker field in the template and it will be set as the default date in the datepicker when rendered in the template form.  The supported formats for the default value are specified here:  http://api.jqueryui.com/datepicker/#option-defaultDate

           

          Ignore the "Date" type option since the template cannot dynamically construct a date.  However, the Number and String formats will work.  Setting the value to a number will allow you to specify the number of days to add/substract from today's date to create the default value.  In your case, setting the value to "0" should work exactly as you would expect, and set the value to today's date.  You can also set a specific date using the date format of the template and using that to create a date value for the datepicker.

           

          Hope that makes sense.  Anyway, thanks for the feedback, and we'll be sure to get this feature out in the next release.  Within the next week or so.

            • Re: Auto-load current date ?
              lsdean

              Looking forward to having it active!

               

              Once it is released and I've implemented it the question will be marked ANSWERED.

               

              Many, many thanks.

               

              Linda

                • Re: Auto-load current date ?

                  The update has been released to the apps market.  You should now have this functionality available.  The one caveat - the number format doesn't work, not as a straight number.  The version of UI components we are using don't seem to support that.  However, the String format does work.  Using the String value you can either provide a date String in the template's date format (default is mm/dd/yyyy) or you can provide a value that is +/- the amount of days from today.  The String value of "+0" should still work to provide you with the current date pre-populated in the date field.  "+7" would be one week from today and "-7" would be a week ago, any number in that pattern should work.