diff --git a/app/config/services.yml b/app/config/services.yml index a99355569..75d07f552 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -28,11 +28,6 @@ services: tags: - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } - app.form.type.datetimepicker: - class: AppBundle\Form\Type\DateTimePickerType - tags: - - { name: form.type, alias: app_datetimepicker } - # Uncomment the following lines to define a service for the Post Doctrine repository. # It's not mandatory to create these services, but if you use repositories a lot, # these services simplify your code: diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index 61a0f94a4..b2be81c3a 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -74,8 +74,8 @@ public function newAction(Request $request) $post->setAuthorEmail($this->getUser()->getEmail()); // See http://symfony.com/doc/current/book/forms.html#submitting-forms-with-multiple-buttons - $form = $this->createForm(new PostType(), $post) - ->add('saveAndCreateNew', 'submit'); + $form = $this->createForm('AppBundle\Form\PostType', $post) + ->add('saveAndCreateNew', 'Symfony\Component\Form\Extension\Core\Type\SubmitType'); $form->handleRequest($request); @@ -146,7 +146,7 @@ public function editAction(Post $post, Request $request) $entityManager = $this->getDoctrine()->getManager(); - $editForm = $this->createForm(new PostType(), $post); + $editForm = $this->createForm('AppBundle\Form\PostType', $post); $deleteForm = $this->createDeleteForm($post); $editForm->handleRequest($request); diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 670662b41..826c2c8b6 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -74,7 +74,7 @@ public function postShowAction(Post $post) */ public function commentNewAction(Request $request, Post $post) { - $form = $this->createForm(new CommentType()); + $form = $this->createForm('AppBundle\Form\CommentType'); $form->handleRequest($request); @@ -111,7 +111,7 @@ public function commentNewAction(Request $request, Post $post) */ public function commentFormAction(Post $post) { - $form = $this->createForm(new CommentType()); + $form = $this->createForm('AppBundle\Form\CommentType'); return $this->render('blog/_comment_form.html.twig', array( 'post' => $post, diff --git a/src/AppBundle/Form/CommentType.php b/src/AppBundle/Form/CommentType.php index 486acb4dc..7007aa6bb 100644 --- a/src/AppBundle/Form/CommentType.php +++ b/src/AppBundle/Form/CommentType.php @@ -52,14 +52,4 @@ public function configureOptions(OptionsResolver $resolver) 'data_class' => 'AppBundle\Entity\Comment', )); } - - /** - * {@inheritdoc} - */ - public function getName() - { - // Best Practice: use 'app_' as the prefix of your custom form types names - // see http://symfony.com/doc/current/best_practices/forms.html#custom-form-field-types - return 'app_comment'; - } } diff --git a/src/AppBundle/Form/PostType.php b/src/AppBundle/Form/PostType.php index 9895a74d8..084bdb77a 100644 --- a/src/AppBundle/Form/PostType.php +++ b/src/AppBundle/Form/PostType.php @@ -43,13 +43,13 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'attr' => array('autofocus' => true), 'label' => 'label.title', )) - ->add('summary', 'textarea', array('label' => 'label.summary')) - ->add('content', 'textarea', array( + ->add('summary', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', array('label' => 'label.summary')) + ->add('content', null, array( 'attr' => array('rows' => 20), 'label' => 'label.content', )) - ->add('authorEmail', 'email', array('label' => 'label.author_email')) - ->add('publishedAt', 'app_datetimepicker', array( + ->add('authorEmail', null, array('label' => 'label.author_email')) + ->add('publishedAt', 'AppBundle\Form\Type\DateTimePickerType', array( 'label' => 'label.published_at', )) ; @@ -64,14 +64,4 @@ public function configureOptions(OptionsResolver $resolver) 'data_class' => 'AppBundle\Entity\Post', )); } - - /** - * {@inheritdoc} - */ - public function getName() - { - // Best Practice: use 'app_' as the prefix of your custom form types names - // see http://symfony.com/doc/current/best_practices/forms.html#custom-form-field-types - return 'app_post'; - } } diff --git a/src/AppBundle/Form/Type/DateTimePickerType.php b/src/AppBundle/Form/Type/DateTimePickerType.php index 464bad971..0a480f8b4 100644 --- a/src/AppBundle/Form/Type/DateTimePickerType.php +++ b/src/AppBundle/Form/Type/DateTimePickerType.php @@ -60,14 +60,6 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return 'datetime'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'app_datetimepicker'; + return 'Symfony\Component\Form\Extension\Core\Type\DateTimeType'; } }