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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:13:27+00:00 2026-05-27T09:13:27+00:00

By default a form_row(form.name) is rendered as something like: <div><label for=form_name class= required>Name</label><input type=text

  • 0

By default a form_row(form.name) is rendered as something like:

<div><label for="form_name" class=" required">Name</label><input type="text" id="form_name" name="form[name]" required="required" maxlength="45" value=""></div>

How/where can I change the behaviour of form_row() to for example:

<div class="someClassName"><label for="form_name" class=" required">Name</label></div><div class="someOtherClassName"><input type="text" id="form_name" name="form[name]" required="required" maxlength="45" value=""></div>
  • 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-27T09:13:28+00:00Added an answer on May 27, 2026 at 9:13 am

    You can check this URL: http://symfony.com/doc/2.0/cookbook/form/form_customization.html#cookbook-form-theming-methods

    There’s a paragraph about customizing form_row().

    Here’s a simple example. By default, form_row() would create a simple html structure like this:

    TWIG:

    {{ form_row(form.email, { 'label' : 'Your email address' }) }}
    

    HTML:

    <div>
        <label for="register_email" class=" required">Your email address</label>
        <input type="email" id="register_email" name="register[email]" required="required" />
    </div>
    

    So, according to the docs, you can create a new twig template, and add class=”form_row” to surrounding the field and label. Place it in YourBundle/views/Form/fields.html.twig and put the following code in there:

    {% block field_row %}
    <div class="form_row">
        {{ form_label(form) }}
        {{ form_errors(form) }}
        {{ form_widget(form) }}
    </div>
    {% endblock field_row %}
    

    In your template file, add the following line:

    {% form_theme form 'YourBundle:Form:fields.html.twig' %}
    

    Now, the form_row template from that file you created will be used, and will return the following HTML code:

    <div class="form_row">
        <label for="register_email" class=" required">Email</label>        
        <input type="email" id="register_email" name="register[email]" required="required" />
    </div>
    

    Hope that it helps.

    • 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 the following dynamically added row: <input type=text name=statuseffective id=statuseffective_0
I have a a form: <form id=deletesubmit style=display:inline > <input style=width:50px type=text id=delcustomerid name=delcustomerid
I am having a problem assigning a default value to my Spring Form input
Hai I am having a form which contains a filetype like this <tr><td> <input
How does one set a default value for a text input using ActiveScaffold 1.2RC1?
How do I set form number four as the default form that will run
C# question: I have a textBox in a default form Form1 and I want
I've noticed that the MS ajax framework touches the action of the default form
By default the form post CSRF protection in Rails creates an authenticity token for
By default, Zend_Form creates a hidden input field for each checkbox input in the

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.