Task #9135

Task #26664: Clean up Form ViewHelpers

Task #26658: Make Form ViewHelpers consistent

FormViewHelper cannot get the value of DateTime

Added by Michael Feinbier almost 6 years ago. Updated about 4 years ago.

Status:Rejected Start date:2010-08-04
Priority:Won't have this time Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:ViewHelpers
Target version:TYPO3 Flow Base Distribution - 1.0.0
Has patch:No

Description

Hey,

not quite shure if i did something wrong but I think I found a misbehaviour in the AbstractFormViewHelper. It seems that DateTime-Fields are not read correctly.

My model has a property:

/**
 * Produktdatum
 * @var DateTime
 * @validate NotEmpty
 */
protected $product_date;

Now if I try to read the value of the field in a form like this:

<f:form.hidden property="warranty_date" id="hidden_warranty_date" />

the value of the hidden form is empty.
The property itself is stored correctly because:
{f:format.date(date: '{newArticle.warranty_date}', format: 'd-m-Y')}
written just next to the hidden form gives me the correct date.

So I think the $this->getValue() in the AbstractFormViewHelper is not able to determine the value of the DateTime object? Maybe it should echo the Unix-Timestamp? (@12353534)

History

#1 Updated by Michael Feinbier almost 6 years ago

There's a small typo above:
My model has two properties $product_date and $warranty_date which are both DateTime properties. But both fields behave the same. So just imagine the property mentioned above is $warranty_date

#2 Updated by Sebastian Kurfuerst about 4 years ago

  • Parent task set to #26658

#3 Updated by Bastian Waidelich about 4 years ago

  • Status changed from New to Rejected
  • Priority changed from Must have to Won't have this time
  • Target version deleted (1.0 beta 2)
  • Has patch set to No

Hidden fields can only render string values.
If you want to put the timestamp of a DateTime into a hidden field you can do so like:

1<f:form.hidden value="{f:format.date(date: '{newArticle.warranty_date}', format: 'U')}" name="yourpluginnamespace[warranty_date]" id="hidden_warranty_date" />

But preferably you should use a special DateTime ViewHelper (that could for instance display a JS calendar and store the date in a format the DateTimeConverter can handle)

Feel free to re-open if you don't agree

Also available in: Atom PDF