From 488bfa0975b396700219e4cfa594d172dc925e39 Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 15 Sep 2012 23:33:31 +0200 Subject: [PATCH] Added date actualization possibility --- src/GergelyPolonkai/FrontBundle/Controller/AdminController.php | 3 +++ src/GergelyPolonkai/FrontBundle/Form/PostType.php | 1 + 2 files changed, 4 insertions(+) diff --git a/src/GergelyPolonkai/FrontBundle/Controller/AdminController.php b/src/GergelyPolonkai/FrontBundle/Controller/AdminController.php index 35da08c..9024b22 100644 --- a/src/GergelyPolonkai/FrontBundle/Controller/AdminController.php +++ b/src/GergelyPolonkai/FrontBundle/Controller/AdminController.php @@ -73,6 +73,9 @@ class AdminController extends Controller if ($request->getMethod() === 'POST') { $form->bind($request); if ($form->isValid()) { + if ($form->get('updateDate')->getData() == 1) { + $post->setCreatedAt(new \DateTime('now')); + } $post->setUser($user); $em = $this->getDoctrine()->getEntityManager(); $em->persist($post); diff --git a/src/GergelyPolonkai/FrontBundle/Form/PostType.php b/src/GergelyPolonkai/FrontBundle/Form/PostType.php index 2f7e7d6..244e5ae 100644 --- a/src/GergelyPolonkai/FrontBundle/Form/PostType.php +++ b/src/GergelyPolonkai/FrontBundle/Form/PostType.php @@ -13,6 +13,7 @@ class PostType extends AbstractType $builder ->add('title') ->add('draft', null, array('required' => false)) + ->add('updateDate', 'checkbox', array('property_path' => false, 'required' => false, 'label' => 'Update creation date')) ->add('content', 'ckeditor') ; }