Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:14:55+00:00 2026-06-17T05:14:55+00:00

/ Edited / I have this class: namespace Baza\BlogBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use

  • 0

/Edited/

I have this class:

namespace Baza\BlogBundle\Form;   
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityManager; 

class filterType extends AbstractType
{

  protected $em;
  public function __construct(EntityManager $em)
 {
     $this->em = $em;
 }
public function buildForm(FormBuilderInterface $builder, array $options)
{

   $this->$em->getDoctrine()->getEntityManager();

   /****
   ****/

 }
}

And this is my services yml:

services:
 filterType:
    class: Baza\BlogBundle\Form\filterType
    arguments: [doctrine.orm.entity_manager]

When I run the code I get following exception:

Catchable Fatal Error: Argument 1 passed to Baza\BlogBundle\Form\filterType::__construct() must be an instance of Doctrine\ORM\EntityManager, none given

I’m all out of ideas.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:14:56+00:00Added an answer on June 17, 2026 at 5:14 am

    I created the FormType myself. This should work:

    <?php
    // Baza\BlogBundle\Form\filterType.php
    
    namespace Baza\BlogBundle\Form;  
    
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Doctrine\ORM\EntityManager;
    
    class filterType extends AbstractType
    {
      protected $em;
    
      public function __construct(EntityManager $em)
      {
         $this->em = $em;
      }
    
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
        // Do something with your Entity Manager using "$this->em"
      }
    
      public function getName()
      {
          return 'filter_type';
      }
    }
    

    In your Controller use something like

    <?php
    // Baza\BlogBundle\Controller\PageController.php
    
    namespace Baza\BlogBundle\Controller;
    use Baza\BlogBundle\Form\filterType;
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    
    class BaseController extends Controller
    {
         public function testEntityManager()
         {
             // assign whatever you need
             $enquiry = null;
             // getEntityManager() is depricated. Use getManager() instead.
             $em = $this->getDoctrine()->getManager();
    
             $this->createForm(
                 new filterType($em),
                 $enquiry
             );
         } 
    }
    

    Never forget to include/use all the classes you are using. Otherwise PHP will assume the class is inside your currently used namespace.

    That’s why you got the error (on Cerad’s post)

    Catchable Fatal Error: Argument 1 passed to
    Baza\BlogBundle\Form\filterType::__construct()
    must be an instance of Baza\BlogBundle\Form\EntityManager [...]
    

    As you didn’t include the EntityManager PHP assumes it’s a class inside your current namespace which was Baza\BlogBundle\Form.


    The funny looking Class EntityManager50ecb6f979a07_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrin‌​e\ORM\EntityManager is a Doctrine2 proxy class.

    Since Symfony 2.1, calling $this->getDoctrine()->getEntityManager() no lonoger results in a Doctrine\ORM\EntityManager but a proxy class which in fact behaves just like the original EntityManager and can be passed without problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code inside a header (edited): template <int i> class A {};
I have this code that I've edited: http://pastebin.com/vrqHek6S I've put in comments where I
--edited for clarity (hopefully) I have an XML file that looks something like this:
I have the following Models and ViewModels (edited for brevity): public class Advert {
I have this code structure: public abstract class ContentEntryBase { public string UniqueIdentifier; public
I have a class in crawl.py that's like this: from myapp.crawl import ScrapyCommand class
This is part of a larger project. Basically I have a class X to
I have this class public final class AsyncTaskManager<T extends AsyncTask<?, ?, ?> & IProgressTrackerTask
I have edited the code by using setOnClick pending intent, and this code works
You Have edited script according to v2 i am getting this error on using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.