Zum Inhalt springen

Datetime-local: Fehlermeldung beim Validieren

Erstellt am 8. März 2017 · 2 Antworten · letzte Antwort am 22. März 2017

Tags: Frage

getit ·

Ich habe ein ähnliches Problem wie im Thread '@validate DateTime NUR Time'. Ich habe auch in diesem Thread gepostet. Aber da der Thread als erledigt markiert war, hab ich einen neuen aufgemacht - sorry für den Doppelpost.

Also ich habe ein Datetime-local-Feld in meinem Formular. Wenn ich das Formular abschicke erhalte ich eine Fehlermeldung: The date "2017-02-01T01:01" was not recognized (for format "d.m.Y H:i" ). | 1307719788 | Arguments: 2017-02-01T01:01

Im Controller:

public function initializeAddAction() {
  $this->arguments['blog']
    ->getPropertyMappingConfiguration()
    ->forProperty('date')
    ->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'd.m.Y H:i');
}

und

/**
 * @param Blog|null $blog
 */
public function addFormAction(Blog $blog = null) {
  $this->view->assign('blog', $blog);
}
/**
 * @param Blog $blog
 */
public function addAction(Blog $blog) {
  $this->blogRepository->add($blog);
  $this->redirect('list');
}

und im Form, als Test nur:

f:form action="add" object="{blog}" name="blog" additionalAttributes="{role:'form'}">
<div class="form-group">
  <label>Date</label>
  <f:form.textfield property="date" class="form-control" type="datetime-local" />
</div>

Ich verwendet TYPO3, 7.6.15 aber auch unter der aktuellen Version funktionierts nicht.

getit ·

Hat leider auch nicht funktioniert. Immer noch die gleiche Fehlermeldung.

Mein Formular sieht (zum Testen) so aus:

<f:render partial="Error" arguments="{object:'leistung'}"/>

<f:form action="add" object="{leistung}" name="leistung" additionalAttributes="{role:'form'}">
  <div class="form-group">
    <label>Datum</label>
    <f:form.textfield property="stand" value="{f:format.date(format: 'd.m.Y H:i')}" type="datetime-local"/>
  </div>
  <f:form.submit value="Erzeugen!"/>
</f:form>

Und das Error-Partial, die mir den Fehler der Validierung meldet:

<f:form.validationResults for="{object}">
  <f:if condition="{validationResults.flattenedErrors}">
    <div class="alert alert-danger">
      <f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath">
        {propertyPath}
	<ul>
	  <f:for each="{errors}" as="error">
	    <li>
	      {error} | {error.code}
	      <f:if condition="{error.arguments}">
	        | Argumente:
	        <f:for each="{error.arguments}" as="argument" iteration="i">
	          {argument}
		  {f:if(condition: i.isLast, then: '', else: ', ')}
	        </f:for>
	      </f:if>
	    </li>
	  </f:for>
	</ul>
      </f:for>
    </div>
  </f:if>
</f:form.validationResults>

Die Ausgabe der Validierung ist:
stand
The date "2020-04-02T01:03" was not recognized (for format "Y-m-d\TH:i:sP "). | 1307719788 | Argumente: 2020-04-02T01:03 , Y-m-d\TH:i:sP

Die Fehlermeldung bleibt die Gleiche, egal ob ich in meinem Controller eine Funktion initializeAddAction()

public function initializeAddAction() {
  $this->arguments['leistung']
       ->getPropertyMappingConfiguration()
       ->forProperty('date')
       ->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'd.m.Y H:i');
}

anlege.

Kennt denn niemand eine Lösung?