Defaulting date to today in custom form


(Kate Needham) #1

I'm trying out the custom form asset, and am using the date/time field type. I'd like to be able to default the field to today's date. Is there any way to do this?


(Kate Needham) #2

Just curious if there's someone who knows about custom forms and can answer this yet?


(Luke Wright) #3

This is not able to be done in the current (3.4) series, and will require development time to implement for it to appear in the 3.5/3.6 series of Matrix.


(Kate Needham) #4

I’ve logged a feature request on the bug tracker (bug #563).


(Michael Williams) #5

I can’t believe that this has never been addressed - just seems to have been forgotten about.
I’ve developed a hack that defaults the date to today, but it’s a real hack and adds a lot of work to the creation of your form.
An example is at https://vfa.vic.gov.au/db/total-stocked,-listed-by-species and I’ve used it many times, because setting it to default to now is incredibly useful.
I’m currently webmaster for the VFA Matrix site and the second date entry field always defaults to today.
How could a million users not have followed up on this as a request.
It’d be great to have a simple tick box that says “default to now”.
I don’t have admin access, so I did that with just web editor access and built-in tools (we’re on ver 5.1.0 ATM).
Tag me if you want me to share the instructions here.


(Bart Banda) #6

Yea currently there isn’t a way to do that, but there is for metadata date fields.

We do have it on the roadmap though and should be available in a version release in the next month or so.

The workaround for now would be to use SSJS or client side JS.


(Michael Williams) #7

My solution was to create common form components which can be nested, and use keyword replacements

    Jan
    Feb
    Mar
    Apr
    May
    Jun
    Jul
    Aug
    Sep
    Oct
    Nov
    Dec