[TYPO3-mvc] DateOfBirth in a form field
Robert Schneider
r.schneider at artworx.at
Tue Jul 31 17:58:44 CEST 2012
I've have found it out by myself after hours. The correct usage in fluid
(at least in Typ3 4.7.1) is:
<f:form.textfield property="dateOfBirth"
value="{f:format.date(format:'d.m.Y', date: '{user.dateOfBirth}')}" />
I didn't know, that the value attribute is used. I thought that the use
of property would ignore the name and the value attribute.
However, the field is not declared in
Tx_Extbase_Domain_Model_FrontendUser. I don't know why. So I have added
it to my derived class:
/**
* Date of birth
*
* @var DateTime
*/
protected $dateOfBirth;
/**
* Sets the dateOfBirth
*
* @param DateTime $dateOfBirth
*
* @return void
*/
public function setDateOfBirth($dateOfBirth) {
$this->dateOfBirth = $dateOfBirth;
}
/**
* Returns the dateOfBirth
*
* @return DateTime $dateOfBirth
*/
public function getDateOfBirth() {
return $this->dateOfBirth;
}
And I have declared it for the TCA in ext_tables.php:
'date_of_birth' => array(
'exclude' => 0,
'label' =>
'LLL:EXT:myextension/Resources/Private/Language/locallang_db.xlf:tx_myderivedclass.date_of_birth',
'config' => array(
'type' => 'input',
'size' => 10,
'eval' => 'date',
'checkbox' => 0,
'default' => time()
),
),
and extended this:
$TCA['fe_users']['types']['Tx_Psa_PsaUser']['showitem'] .= "date_of_birth";
I hope this helps anyone. At least, I'm so glad that it works now.
This was my help:
http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2011-May/009558.html
Regards,
Robert
> Hi,
>
> the date of birth in the fe_users table is a unix timestamp. There is a
> way to show a date with f:format.date in Fluid. However, how can I make
> the field editable in a form? Is this possible with the property
> attribute? Or must I avoid it and do the conversions both manually in
> the controller with php functions (both ways: timestamp to string and
> string to timestamp)?
>
> Regards,
> Robert
More information about the TYPO3-project-typo3v4mvc
mailing list