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 8030955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:56:25+00:00 2026-06-05T00:56:25+00:00

I am trying to edit a form i get the form with existing values

  • 0

I am trying to edit a form i get the form with existing values correctly but when i try to put new data in fields and submit the form i get an error of Call to a member function setName() on a non-object

My controller method is

public function editAction(Request $request){
$request = Request::createFromGlobals();
    $group_id = $request->query->get('id');
    $em = $this->getDoctrine()->getEntityManager();
    $patent_group = $em->getRepository('MunichInnovationGroupBundle:PmPatentgroups')->find($group_id);
    //echo '<pre>';
    //print_r($patent_group);
    //echo '</pre>';
    $form = $this->createForm(new PatentgroupType(), $patent_group);
    if ($request->getMethod() == 'POST') {
        $form->bindRequest($request);
        $name = $form["name"]->getData();
        $description = $form["description"]->getData();
        $patent_group->setName($name);
        $patent_group->setDescription($description);
        $em->flush();
        return $this->redirect($this->generateUrl('MunichInnovationGroupBundle_portfolio'));
    }
    return $this->render('MunichInnovationGroupBundle:Patentgroups:edit.html.twig', array(
            'form' => $form->createView(),
            'group_id' => $group_id
    ));
}

This is what I get in $patent_group

 MunichInnovationGroup\Bundle\Entity\PmPatentgroups Object
(
[id:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => c3e0eb98-ada5-11e1-96a5-9787dec335c2
[name:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => Zoha Ali khan
[description:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => No Description Provided for this Group
[portfolio_id:MunichInnovationGroup\Bundle\Entity\PmPatentgroups:private] => Proxies\MunichInnovationGroupBundleEntityPmPortfoliosProxy Object
    (
        [_entityPersister:Proxies\MunichInnovationGroupBundleEntityPmPortfoliosProxy:private] => Doctrine\ORM\Persisters\BasicEntityPersister Object
            (
                [_class:protected] => Doctrine\ORM\Mapping\ClassMetadata Object
                    (
                        [reflFields] => Array
                            (
                                [id] => ReflectionProperty Object
                                    (
                                        [name] => id
                                        [class] => MunichInnovationGroup\Bundle\Entity\PmPortfolios
                                    )

                                [portfolioName] => ReflectionProperty Object
                                    (
                                        [name] => portfolioName
                                        [class] => MunichInnovationGroup\Bundle\Entity\PmPortfolios
                                    )

What i am doing wrong here as i am getting this error

Call to a member function setName() on a non-object  

Any Ideas?
Thanks in advance

  • 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-05T00:56:26+00:00Added an answer on June 5, 2026 at 12:56 am

    My Fix: Kindly comment whether it is a good solution or not

    public function editAction(Request $request){
        $request = Request::createFromGlobals();
        $group_id = $request->query->get('id');
        $em = $this->getDoctrine()->getEntityManager();
        $patentgroup = $em->getRepository('MunichInnovationGroupBundle:PmPatentgroups')->findOneBy(array('id'=>$group_id));
        $form = $this->createForm(new PatentgroupType(), $patentgroup);
        if ($request->getMethod() == 'POST') {
            $form->bindRequest($request);
            $group_id = $form["id"]->getData();
            $name = $form["name"]->getData();
            $description = $form["description"]->getData();
            $em = $this->getDoctrine()->getEntityManager();
            $patentgroup = $em->getRepository('MunichInnovationGroupBundle:PmPatentgroups')->findOneBy(array('id'=>$group_id));
            $patentgroup->setName($name);
            $patentgroup->setDescription($description);
            $em->flush();
            return $this->redirect($this->generateUrl('MunichInnovationGroupBundle_portfolio'));
        }
        return $this->render('MunichInnovationGroupBundle:Patentgroups:edit.html.twig', array(
                'form' => $form->createView(),
                'group_id' => $group_id
        ));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to edit an existing object through a form. Every thing is working
I am trying to add a simple form to allow my users to edit
I'm trying to edit a form, the route is controller/id/action for edit so for
I am trying to get a form field value after the form has been
I'm new to nHibernate, and trying to get my head around the proper way
New to rails and trying to get a one to many relationship up and
I'm trying to work on an existing website and I've found a bug, but
This is a stupid example but I'm trying to understand how thing get passed
I'm trying to render the Devise edit password form within another view because I
<form onsubmit=submit(); return false; name=text id=form method=get> <input type=feild style=font-size: 150%; id=field name=field value=

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.