Datepicker in backend module

Hi,

I’ve allready managed to have the jQuery datepicker in my forms (actionNew, actionEdit).
One can choose a date, and that date appears in the respective input field.
Problem: On submit, the value is not saved. No errors.
The field is of the type string. Manually one can store a date like 2016-09-23.

Any hints?

Is there an example of a full fledged form for backend modules (e.g. choosing an image …)?

Cheers
Klaus

Hi Klaus,

I’m pretty certain the problem lies on your end on how you’re integrating the datepicker (most likely the actual form input field value is not set). There’s shouldn’t be anything interfering with that in Neos.

Don’t know of any examples with rich form editors, but anything can be done more or less.

Cheers,
Aske

Hi Aske,

I found the problem:

I use the datepicker form viewhelper in the updateAction

        <li>
            <label for="projectCreationDate">Planungsbeginn</label>
            <form:form.datePicker property="projectCreationDate" id="projectCreationDate" enableDatePicker="true" dateFormat="yy-m-d"></form:form.datePicker>
            <span style="color:yellow;">{pvProject.projectCreationDate}</span>
        </li>

This resutts in the following HTML:

     <li>
          <label for="projectCreationDate">Planungsbeginn</label>
          <input id="projectCreationDate" type="text" name="moduleArguments[pvProject][projectCreationDate][date]" readonly="1" />
<input type="hidden" name="moduleArguments[pvProject][projectCreationDate][dateFormat]" value="yy-m-d" />
<script type="text/javascript">//<![CDATA[
    				$(function() {
    					$("#projectCreationDate").datepicker({
    						dateFormat: "yy-mm-dd"
    					}).keydown(function(e) {
    							// By using "backspace" or "delete", you can clear the datepicker again.
    						if(e.keyCode == 8 || e.keyCode == 46) {
    							e.preventDefault();
    							$.datepicker._clearDate(this);
    						}
    					});
    				});
    				//]]></script>
         <span style="color:yellow;">{pvProject.projectCreationDate}</span>
      </li>

The domain model has a property “projectCreationDate” (string).
The form has two input fields named “[pvProject][projectCreationDate][date]” and [pvProject][projectCreationDate][dateFormat].
On update they are merged together and saved in the domain model property “projectCreationDate”, as we see in the span tag.

So I somehow have to rewrite [projectCreationDate][date] to [projectCreationDate], without the formatString.

Can you (or somebody else) advice me, how to deal with it.

  • I was adviced, not to use the \Date type in the model (it’s string), but perhaps this solve the problem??
  • Should I use property mapping?
  • Hook into the update method of the repository (I consider this q & d).

Thanks
Klaus

Oh, never used the date picker view helper from the form package. I’d assume you could just use a normal input field instead. However for that view helper to work, you’d definitely need to use \DateTime as the property type in your model and use the build in property mapping. In general not using \DateTime should like terrible advice, what’s the reasoning behind it?