[TYPO3-mvc] Re: How to set default values for a new Model object?

Martin Terber mterber at gmx.net
Wed Jul 3 23:15:42 CEST 2013


Quote: Armin Rüdiger Vieweg wrote on Sat, 19 March 2011 12:30
----------------------------------------------------
> 
> If possible I would set the default values for a model in its attributes:
> 
> class Tx_Extension_Domain_Model_Person extends  
> Tx_Extbase_DomainObject_AbstractEntity {
> 	protected $firstname = 'John';
> 	protected $name = 'Doe';
> 	// ...
> }
> 
----------------------------------------------------

I don't fully understand. This doesn't work, obviously:
[php]
	/**
	 * Date of last change (from Frontend)
	 *
	 * @var DateTime
	 */
	protected $lastChange = time();
[/php]

So I did this, after submitting data, before saving to db:
[php]
public function createAction(Tx_Extension_Domain_Model_Object $object) {
   $object->setLastChange(time());
}
[/php]

Is that good practise?

-- 
TYPO3 + PHP development
www.martinterber.com


More information about the TYPO3-project-typo3v4mvc mailing list