Am using the Pikaday datepicker to add a Date field to the front-end of a Craft site: https://github.com/dbushell/Pikaday

This is for integration with the Formerly add-on and the date is set to required.

When I try to submit the form I get the following error:

2016/02/03 12:23:54 [warning] [application] Craft\ContentModel->dateTest_testDate failed validation: Test Date cannot be blank.

Are date inputs submitted via the front-end required in a particular format?

  • also experiencing same problem with Sprout Forms
  • Cole, could you provide an example of the date and time format you are using to submit your fields? This is a handy resource on the input format needed: straightupcraft.com/articles/… Commented Feb 5, 2016 at 14:37
  • Hi @BenParizek - I've tried several different. DD-MM-YYYY, MM-DD-YYYY, YYYY-MM-DD and YYYY-MM-DD HH:MM:SS. All seem to fail Commented Feb 5, 2016 at 14:49
  • Sorry, to provide some more context/info date is defined by custom template/HTML and is required. For example, for a date field set as child1DateOfBirth am accessing as: <input name="fields[child1DateOfBirth]" required="required" type="text" /> Commented Feb 5, 2016 at 15:00
  • Any further thoughts on this @ben? Commented Feb 6, 2016 at 9:30

1 Answer 1


The input tag presented in the comments above does not appear to use the correct input tag format for the date field. To submit a date field on the front-end, your input fields need to be setup with the following name structure and value format:

<input type="text" size="10" name="fields[fieldHandle][date]" value="10/15/2012">
<input type="text" size="10" name="fields[fieldHandle][time]" value="6:12 PM">

Using your example field handle of child1DateOfBirth this would be:

<input type="text" size="10" name="fields[child1DateOfBirth][date]" value="10/15/2012">
<input type="text" size="10" name="fields[child1DateOfBirth][time]" value="6:12 PM">

To submit any field on the front-end of Craft requires that you use the right format for the input field you are submitting. Assuming the field submits just fine from within Craft, one way to track down the format you need on the front-end is to use your browser's developer tools and look at the input tags for the respective field in the Craft control panel.

The Craft CMS Field Guide on Straight Up Craft is another resource that gives examples of all the different native Craft fields and examples of input fields for the front-end.

If things currently aren't working, consider trying to hard code these values and confirm that this works at all. You'll then need to figure out how to get the respective datepicker you are using to format the selected data into the proper input format as described above.

I don't believe this is an issue with any specific form plugin being used. In the case you wanted to use a dynamic date field with your form (instead of manually creating your form as you describe above), you could extend Sprout Forms and add support for a custom front-end field.

  • 1
    It's worth mentioning that the date format for an input field appears to be different for certain locales, aswell – so for a multilingual site it's often necessary to have a locale conditional for the input format. The tip about using the browser's dev tools to figure out how a field input should be formatted is great – I usually check "Preserve log", then submit a form in the CP and look at the request headers. Commented Feb 7, 2016 at 11:08
  • Thanks for the feedback @Ben and @Mats - added [date] to the input and looked at locales formatting but still not saving. If I look into sproutforms.log I get the following error: 2016/02/08 10:59:04 [info] [plugin] Failed to save element in /craft/plugins/sproutforms/services/SproutForms_EntriesService.php (227) in /craft/plugins/sproutforms/controllers/SproutForms_EntriesController.php (176) However the form submission is not throwing back any errors (eg sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/…). Very confused! Commented Feb 8, 2016 at 11:01
  • @ColeHenley Are you hardcoding the value you are submitting or using the js library you mentioned? How are you dumping your errors on the page? Are you sure you are dumping all errors? Consider trying to dump the entire error object using {{ dump(formHandle.getErrors()) }} Commented Feb 8, 2016 at 16:52
  • Thanks for replying Ben. Yes, hard coding without JS library and get the same result. Dumping errors as above within template returns empty arrays. However, I've tried with both Formerly and SproutForms and both seem to validate but the errors are empty. I just get the 'failed to save element' message in the logs. However, if I hack into the controller/service in eg Formerly I get a response which passes the conditional that the submission has returned no errors but it does return errors. See gist.github.com/cole007/16bbc2d09ceff7517602 Any thoughts? Commented Feb 8, 2016 at 21:11
  • Not sure what is up, Cole. I am able to submit a date field to Sprout Forms without any issues. If you'd like us to dig deeper, can you open a ticket and provide your template and an example db to take a closer look at? Commented Feb 9, 2016 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.