<p>The <code>input</code> tag presented in the comments above does not appear to use the correct <code>input</code> 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 <code>name</code> structure and <code>value</code> format:</p>

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

<p>Using your example field handle of <code>child1DateOfBirth</code> this would be:</p>

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

<p>To submit any field on the front-end of Craft requires that you use the right format for the <code>input</code> 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 <code>input</code> tags for the respective field in the Craft control panel.</p>

<p>The <a href="https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input">Craft CMS Field Guide</a> on Straight Up Craft is another resource that gives examples of all the different native Craft fields and examples of <code>input</code> fields for the front-end.</p>

<p>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 <code>input</code> format as described above.</p>

<hr>

<p>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 <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/custom-front-end-fields">custom front-end field</a>.</p>

CC BY-SA 3.0
2016-02-07T11:08:37.100Z
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.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-02-08T11:01:07.073Z
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 http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/examples/display-errors-at-top-of-page). Very confused!
Cole Henley
CC BY-SA 3.0
2016-02-08T16:52:20.897Z
@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()) }}`
Ben Parizek
CC BY-SA 3.0
2016-02-08T21:11:31.687Z
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 https://gist.github.com/cole007/16bbc2d09ceff7517602 

Any thoughts?
Cole Henley
CC BY-SA 3.0
2016-02-09T01:05:47.687Z
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?
Ben Parizek
CC BY-SA 3.0
2016-06-15T16:08:45.730Z
Has this been fixed?  I am having a similar issue with amForms.  I want to post about it in my own ticket but there's this ticket laying open already.
Ryan
CC BY-SA 3.0
2016-02-06T17:21:12.053Z
2016-02-06T17:21:12.053Z
Ben Parizek
<p>Am using the Pikaday datepicker to add a Date field to the front-end of a Craft site: <a href="https://github.com/dbushell/Pikaday" rel="nofollow">https://github.com/dbushell/Pikaday</a></p>

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

<p>When I try to submit the form I get the following error:</p>

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

<p>Are date inputs submitted via the front-end required in a particular format?</p>

<ul>
<li>also experiencing same problem with Sprout Forms</li>
</ul>

CC BY-SA 3.0
2016-02-05T14:37:45.193Z
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: https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input
Ben Parizek
CC BY-SA 3.0
2016-02-05T14:49:07.943Z
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
Cole Henley
CC BY-SA 3.0
2016-02-05T15:00:47.623Z
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" />`
Cole Henley
CC BY-SA 3.0
2016-02-06T09:30:38.643Z
Any further thoughts on this @ben?
Cole Henley
<field><datetime><frontend><plugin-sproutforms><plugins-formerly>
Error when submitting Date Field from the front-end: cannot be blank
# Error when submitting Date Field from the front-end: cannot be blank

(Asked by: username_0 on 2016-02-03)

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

**Tags:** field, datetime, frontend, plugin-sproutforms, plugins-formerly

> **Comments:**
> **username_1**: 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: https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input  
> **username_0**: 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  
> **username_0**: 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" />`  
> **username_0**: Any further thoughts on this @ben?  

---

## 1 answers

### Answer by username_1 on 2016-02-06. Score: 5

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:



Using your example field handle of child1DateOfBirth this would be:



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.

> **Comments:**
> **username_2**: 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.  
> **username_0**: 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 http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/examples/display-errors-at-top-of-page). Very confused!  
> **username_1**: @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()) }}`  
> **username_0**: 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 https://gist.github.com/cole007/16bbc2d09ceff7517602   Any thoughts?  
> **username_1**: 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?  
> **username_3**: Has this been fixed?  I am having a similar issue with amForms.  I want to post about it in my own ticket but there's this ticket laying open already.  

---

