To add some some default field value whith SonataAdminBundle you should use the getNewInstance function :
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public function getNewInstance() { $instance = parent::getNewInstance(); $container = $this->getConfigurationPool()->getContainer(); $user = $container->get('security.context')->getToken()->getUser(); $instance->setUser($user); $oNow = new \DateTime('now'); $instance->setStartDate($oNow); $instance->setEndDate($oNow->modify('+1 month')); return $instance; } |
No comments yet.