2014-02-17 82 views

回答

0

,我建議你使用管理類的getNewInstance方法來預先設定在該實體的日期。

例AdminClass

class ExampleAdmin extends Admin 
{ 
    public function getNewInstance() 
    { 
     $instance = parent::getNewInstance(); 

     // Set date to today 
     $dateTime = new \DateTime(); 
     $dateTime->setTime(0, 0, 0); 

     // Instance points to the entity that is being created 
     $instance->setDateDeroulement($dateTime); 

     return $instance; 
    } 

    protected function configureFormFields(FormMapper $formMapper) 
    { 
     .... 
     $formMapper 
      ->add('dateDeroulement','date', 
        array('years' => date('Y'),2020)) 
     ... 
    } 
} 
相關問題