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 12 years ago. Updated almost 11 years ago.

Status:
Rejected
Priority:
Won't have this time
Category:
ViewHelpers
Start date:
2010-08-04
Due date:
% Done:

0%

Estimated time:
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)

#1

Updated by Michael Feinbier almost 12 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 11 years ago

  • Parent task set to #26658
#3

Updated by Bastian Waidelich almost 11 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:

<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