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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:08:40+00:00 2026-06-04T21:08:40+00:00

In Symfony2, I’m using formbuilder. I’m setting the labels in the form, as per

  • 0

In Symfony2, I’m using formbuilder. I’m setting the labels in the form, as per the documentation.

However, when I’m on the ‘show’ and ‘index’ pages, I have to copy the labels into Twig.

Is there a way to have the same labels used everywhere? The options I have thought of:

  • Access the formbuilder configuration, but without actually building the form
  • Have a central config file, and lookup from the formbuilder and the twig files into that file

However, either way requires me to ‘do’ something, which I’m not used to in Symfony. It seems like this is something that would already have been solved, but I’m not sure how.

  • 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-04T21:08:42+00:00Added an answer on June 4, 2026 at 9:08 pm

    You can utilize translation system to overcome this problem. Make sure that you have enabled translation in config.yml.

    If you have added field in your formtype like this

    $builder->add('title', 'text', array(
        'label'=> 'model.title'
    ));
    //.....
    

    Create a file named messages.en.yml in your bundles Resources/translations directory (replace en with your default locale and create multiple files based on the locales. Check translation chapter of the book.) and put following

    #src/YourBundle/Resources/translation/messages.en.yml
    model:
        title: "Title"
        field: "Field"
        #....
    

    Add and edit forms label will show Title. In index and show pages you can do

    {{ "model.title" | trans([], 'messages') }}
    

    Though this process is a bit lengthy but it is one time and you can change the value of the labels by changing the translation files.

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

Sidebar

Related Questions

I have the following Symfony2 form: public function buildForm(FormBuilder $builder, array $options) { $builder
I'm using symfony2. I have a form, and I want to print it a
I have a Symfony2 form with a variety of fields, including one optional text
I'm using Symfony2 and CraueFormFlowBundle to create a multi-step form. Everything is going well
I have a Symfony2's form with two fields: A and B. I want to
I'm using Symfony2 to authenticate users. And I have two databases to store user
i do use symfony2.1 and i have form which i do extend by another
In Symfony2 (2.0.3) I have a BetaBundle that is set as the parent of
I am currently using Symfony2 and Doctrine2 and am trying to join two tables
When I update my Symfony2 project I always have to do this: root@xxx:/var/www/project# php

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.