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

  • Home
  • SEARCH
  • 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 7720899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:47:14+00:00 2026-06-01T03:47:14+00:00

I have want to save a form in Symfony2, based on a form type,

  • 0

I have want to save a form in Symfony2, based on a form type, but the save() method is not found.

The error message is:

Fatal error: Call to undefined method Symfony\Component\Form\Form::save() in C:\xampp\htdocs\Xq\src\Xq\LogBundle\Controller\LogController.php on line 44

The controller that invokes the save method looks as follows:

<?php

namespace Xq\LogBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\Request;

use Doctrine\ORM\EntityRepository;

use Xq\LogBundle\Entity\Call;
use Xq\LogBundle\Form\Type\CallType;

class LogController extends Controller
{

        public function callAction(Request $request)
        {
                #create call object
                    $call = new Call();
                    $now = new \DateTime("now");
                    $call->setTimestamp($now);
                    $call_form = $this->createForm(new CallType(), $call);
                #check form input
                    $request = $this->get('request');
                    if ($request->getMethod() == 'POST')
                    {
                        $call_form->bindRequest($request);
                            if ($call_form->isValid())
                            {
                                **$saved_call = $call_form->save();**
                            }
                    }
                return $this->render('XqLogBundle:log:call.html.twig', array('call_form'=>$call_form->createView()));
        }
}
?>

The CallType is defined as below:

<?php

namespace Xq\LogBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class CallType extends AbstractType
{
    public function buildForm(Formbuilder $builder, array $options)
    {
        //here all fields are defined, and they are rendered fine       
    }

    public function getDefaultOptions(array $options)
    {
        return array('data_class' => 'Xq\LogBundle\Entity\Call');
    }

    public function getName()
    {
        return 'callform';
    }
}
?>

And finally there is an entity class “Call” that works fine as well:

<?php

#ORM mapping of a call

namespace Xq\LogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

 /**
 *
 * Xq\LogBundle\Entity\Call
 *
 * @ORM\Table(name="calls")
 * @ORM\Entity
 */

class Call
{
    #id of the call
        /**
         * @ORM\Id
         * @ORM\Column(type="integer", length="7")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        protected $id;

    #caller
        /**
         * @ORM\Column(name="caller", type="integer", length="3", nullable="false")
         * @ORM\OneToOne(targetEntity="caller")
         * @Assert\type(type="Xq\LogBundle\Entity\Caller")
         */
        protected $caller;

        // and so on ....


    #getters and setters

        /**
         * Get id
         *
         * @return integer $id
         */
        public function getId()
        {
                return $this->id;
        }

        // and so on...

}

Does anybody know why the save method is not found? The bind() method does not trigger an error, so there must be a valid form object I guess.

  • 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-01T03:47:15+00:00Added an answer on June 1, 2026 at 3:47 am

    Forms are not responsible for persisting objects; they are responsible for outputting form fields with values from an object and putting user input into that object on form submit.

    Use Doctrine to persist your objects. Here is the code snippet from the Forms and Doctrine section, adapted for your example:

    if ($call_form->isValid()) {
        $em = $this->getDoctrine()->getEntityManager();
        $em->persist($call);
        $em->flush();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with a save button, but i want users to be
i have a form with some checkboxes on it i want to save those
I have a ListBox on my Form, I want to save it and load
I want to save form position. I have successfully set Form.Location property in ApplicationSettings->PropertyBinding
I have a user form for text phrases and I want to save the
I have a registration form in ASP.NET 2.0. I want to save my registration
I have a text box and a button in a form.i want to save
I have a DataTable which I want to save to a SQLite Database Table.
I have a Seekbar and I want to save the state to database when
i have some element in my container and want to save all properties of

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.