View Single Post
Old 09-15-2019, 10:00 AM
Ed B. Ed B. is online now

Join Date: Apr 2016
Posts: 330

Default Re: Date as column type?

It turns out the things are a bit more complicated. The FormField class

View/FormField/Input/Text/Date.php, as its path suggests, treats dates as strings. So,
I can't do
* @Column (type="integer") */ protected $mydate public getMydate { return $this->mydate } public setMydate($value) { $this->mydate=$value; return $this; }
in the model class (or type="date" for that matter)
and use View/FormField/Input/Text/Date.php for editing the entity, i.e.
protected $schemaDefault = array( ... 'mydate. => array( self::SCHEMA_CLASS => 'XLite\View\FormField\Input\Text\Date' self::SCHEMA_LABEL => 'My Date', self::SCHEMA_REQUIRED => false,), ...
it won't save the date. For the dates to be saved this way, I need to declare the column type as string. The problem is, the "dates" saved this way becomes inaccessible once I change the default formatting of the dates for the store.

The only place, it seems to me, where there is the date to be input manually in X-Cart's original code, is the arrival date for products, but there, the class View/FormModel/Type/DatepickerType.php is used. My entities don't use the DTO, so I can't use this class. So, the question now is: how do I get around this problem?

I would need something like
public setMydate($value) { $value=strtotime($value); $this->mydate=$value; return $this; }
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote