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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:25:27+00:00 2026-05-26T19:25:27+00:00

for all the entity forms of my Symfony2 app, I’d like all labels to

  • 0

for all the entity forms of my Symfony2 app, I’d like all labels to be of the following form: <entity_name>.<field_name>
Having the possibility to change the label afterwards would be cool.

How can I achieve this?

  • 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-05-26T19:25:28+00:00Added an answer on May 26, 2026 at 7:25 pm

    The default label’s behavior is defined in the FieldType:

    https://github.com/symfony/symfony/blob/2.0/src/Symfony/Component/Form/Extension/Core/Type/FieldType.php#L55

    (note: the FieldType class was deprecated in Symfony 2.1 and removed in Symfony 2.3)

    If you want to change the default type’s behavior, you can create an extension:

    https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/AbstractTypeExtension.php

    class FieldTypeEntityLabelExtension
    {
        static $currentTypeName;
        public function buildForm(FormBuilder $builder, array $options)
        {
            $types = $builder->getTypes();
    
            $type = end($types);
    
            $dataClass   = get_class($type);
            if (strpos($dataClass, 'Uc') === 0) // <-- My namespace
            {
                $classParts              = explode( '\\', $dataClass);
                $translationParts        = array_slice($classParts, 3);
                self::$currentTypeName   = implode('.', array_map('Symfony\Component\DependencyInjection\Container::underscore', $translationParts));
            }
    
            if (isset(self::$currentTypeName) && !$options['precious'])
            {
                $builder->setAttribute('label', sprintf('%s.%s', substr(self::$currentTypeName, 0, -5), $builder->getName()));
            }
        }
    
        public function getExtendedType()
        {
            return 'field';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we are getting the following error in almost all create or edit entity forms.
All, If I run a query like the following: $qry = Select wrong_column from
I've got a form in Symfony2 that's not connected to any entity. It has
I am following the tutorial from Symfony2 on how to use form classes. I
all. I would like to ask if it is possible to have multiple forms
I'm having bit complicated object model that forms a triangle. There is User entity
It looks like in edit and add forms all field have fixed width. I
I'm working on a Symfony form with non-entity fields (in a collection). (EDIT: All
I have an entity type form field in my Symfony2 project. $builder = $this->createFormBuilder();
I'm using the entity Field Type in a Symfony2.1 form. Here, I'm going to

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.