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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:02:36+00:00 2026-06-10T07:02:36+00:00

I have this error when I submit my form: Class Symfony\Component\Form\Form is not a

  • 0

I have this error when I submit my form:

Class Symfony\Component\Form\Form is not a valid entity or mapped super class.

The problem comes from the fact that I am trying to persist data to my database in my controller. When i hide that part of code, I have no problem submitting my form. I am using Symfony 2.0.16

Here is the Entity

<?php

namespace Acme\FormsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Acme\FormsBundle\Entity\UserAccount
 */
class UserAccount {
/**
 * @var integer $id
 */
private $id;

/**
 * @var string $user_id
 */
private $user_id;

/**
 * @var string $mail
 */
private $mail;

/**
 * @var string $password
 */
private $password;

/**
 * @var string $role
 */
private $role;

/**
 * @var string $pseudo
 */
private $pseudo;

/**
 * @var string $nom
 */
private $nom;

/**
 * @var string $prenom
 */
private $prenom;

/**
 * @var string $sexe
 */
private $sexe;

/**
 * @var text $freetext
 */
private $freetext;

/**
 * @var boolean $status
 */
private $status;

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

/**
 * Set user_id
 *
 * @param string $userId
 */
public function setUser_id($user_id) {
    $this -> user_id = $user_id;
}

/**
 * Get user_id
 *
 * @return string
 */
public function getUser_id() {
    return $this -> user_id;
}

/**
 * Set mail
 *
 * @param string $mail
 */
public function setMail($mail) {
    $this -> mail = $mail;
}

/**
 * Get mail
 *
 * @return string
 */
public function getMail() {
    return $this -> mail;
}

/**
 * Set password
 *
 * @param string $password
 */
public function setPassword($password) {
    $this -> password = $password;
}

/**
 * Get password
 *
 * @return string
 */
public function getPassword() {
    return $this -> password;
}

/**
 * Set role
 *
 * @param string $role
 */
public function setRole($role) {
    $this -> role = $role;
}

/**
 * Get role
 *
 * @return string
 */
public function getRole() {
    return $this -> role;
}

/**
 * Set pseudo
 *
 * @param string $pseudo
 */
public function setPseudo($pseudo) {
    $this -> pseudo = $pseudo;
}

/**
 * Get pseudo
 *
 * @return string
 */
public function getPseudo() {
    return $this -> pseudo;
}

/**
 * Set nom
 *
 * @param string $nom
 */
public function setNom($nom) {
    $this -> nom = $nom;
}

/**
 * Get nom
 *
 * @return string
 */
public function getNom() {
    return $this -> nom;
}

/**
 * Set prenom
 *
 * @param string $prenom
 */
public function setPrenom($prenom) {
    $this -> prenom = $prenom;
}

/**
 * Get prenom
 *
 * @return string
 */
public function getPrenom() {
    return $this -> prenom;
}

/**
 * Set sexe
 *
 * @param string $sexe
 */
public function setSexe($sexe) {
    $this -> sexe = $sexe;
}

/**
 * Get sexe
 *
 * @return string
 */
public function getSexe() {
    return $this -> sexe;
}

/**
 * Set freetext
 *
 * @param text $freetext
 */
public function setFreetext($freetext) {
    $this -> freetext = $freetext;
}

/**
 * Get freetext
 *
 * @return text
 */
public function getFreetext() {
    return $this -> freetext;
}

/**
 * Set status
 *
 * @param boolean $status
 */
public function setStatus($status) {
    $this -> status = $status;
}

/**
 * Get status
 *
 * @return boolean
 */
public function getStatus() {
    return $this -> status;
}

}

Here is the controller

namespace Acme\FormsBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Acme\FormsBundle\Entity\UserAccount;

class DefaultController extends Controller {

public function newUserAction(Request $request) {
    $newUser = new UserAccount();
    $newUser -> setUser_id('');
    $newUser -> setRole('');
    $newUser -> setNom('');
    $newUser -> setPrenom('');
    $newUser -> setSexe('');
    $newUser -> setFreetext('');
    $newUser -> setStatus('');

    $newUserForm = $this -> createFormBuilder($newUser)
                -> add('pseudo', 'text')
                -> add('mail', 'email')
                -> add('password', 'password')
                -> getForm();

    //if the form has been submitted
    if ($request->getMethod() == 'POST') {
        $newUserForm->bindRequest($request);

        if ($newUserForm->isValid()) {
            //Perform some actions
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($newUserForm);
            $em->flush();

            //Prepare confirmation message
            $this->get('session')->setFlash('notice','Account successfully created');

            //redirect user
            return $this->redirect($this->generateUrl('AcmeWelcomeBundle_homepage'));
        }
    }

    return $this -> render('AcmeFormsBundle:Default:newUser.html.twig', array('form' => $newUserForm -> createView(), ));
}
}

I can’t figure this out.

  • 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-10T07:02:38+00:00Added an answer on June 10, 2026 at 7:02 am

    You should persist your $newUser object, not the form itself.

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

Sidebar

Related Questions

I have this error message could not load assembly 'system.data.entity, version 4.2.0.0, culture=neutral,publickeytoken=b77a5c561934e089' or
I have this form that validates the fields on submit through ajax (using Codeigniter's
When i try to submit the form below i get this error WARNING: Can't
I have this error when trying to generate the meta model with JOOQ: org.jooq.exception.DataAccessException:
I Have this error message : Possible unitended reference comparison; to get a value
I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide
I have this error that is keeping me from moving forward. I basically have
I have this error when I am trying to read the file: Exception in
I have this error appearing in my web service and even though I'v had
I have this error NOTICE: UNDEFINED VARIABLE: LOGO IN C:\WAMP\WWW\SITE\TOOLS\SMARTY\SYSPLUGINS\SMARTY_INTERNAL_DATA.PHP ON LINE 291 CALL

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.