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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:46:51+00:00 2026-06-11T15:46:51+00:00

I have a form type which has a field that is not in the

  • 0

I have a form type which has a field that is not in the entity as a property, but the entity has a getter and a setter with the same name as form field, explaining:

Form type:

$builder->add('theField', 'entity', array(
    'label' => 'The field',
    'class' => 'MyAppBundle:AnEntity',
    'empty_value' => '',
));

Entity:

class User
{
    //There is NOT a property called "theField"

    public function setTheField($value)
    {
        ...
    }

    public function getTheField()
    {
        ...
    }
}

So, I’m expected that Symfony2 call the getter and setter to bind and show the form field, but I get this error:

Property theField does not exists in class My\AppBundle\Entity\User

Is there a way to create this form field without having the property declared in entity?

EDIT

Is strange, but when I declare a private property theField, it’s works (BTW, that is not what I looking for).

  • 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-11T15:46:52+00:00Added an answer on June 11, 2026 at 3:46 pm

    Did you try:

    $builder->add('theField', 'entity', array(
        'label' => 'The field',
        'class' => 'MyAppBundle:AnEntity',
        'empty_value' => '',
        'property_path' => false,
    ));
    

    Update

    Change your field name to the same as attribute in the entity or change 'property_path' to the attribute name.

    $builder->add('theField', 'entity', array(
        'label' => 'The field',
        'class' => 'MyAppBundle:AnEntity',
        'empty_value' => '',
        'property_path' => 'theField',
    ));
    

    And in your entity add:

    private $theField = null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form and one of the fields is a check-all-that-applies type field
Entity has a custom field based on which, some security roles should have access
I have a form which has one field username . If some one submit
I have a form which has a search feature - a single text field
I have a form which POST's its data via AJAX: $.ajax({ type: POST, url:
I have a form which allow users to choose the type of permit they
I have a form with number of submit type as images. Each image has
I have a form that is basically a calculator. you can type an equation
Suppose I have a form like this: Name:<input type=text name=xxx id=name/> Type:<select> <option>xx</option> <option>xx</option>
I have a bit of a conundrum. I have a form which has numerous

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.