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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:48:25+00:00 2026-06-12T14:48:25+00:00

I have an edit form, The form is made through symfony2 Form types. I

  • 0

I have an edit form, The form is made through symfony2 Form types. I checked the documentation but couldn’t find any option for adding CSS to the form. The form display the data correctly and everything is fine what I want to do is to add styling to each field.

My Edit Type is

 public function buildForm(FormBuilder $builder, array $options)
{
    $builder
    ->add('id', 'hidden')
    ->add('patent_name', 'text', array('label' => 'Patent Name'))
    ->add('description', 'textarea', array('label' => 'Description', 'required' => false))
    ->add('appln_auth','text', array('label' => 'Application Authorization'))
    ;
}

Anyone has any idea ho I can add css ?

Thanks

  • 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-12T14:48:27+00:00Added an answer on June 12, 2026 at 2:48 pm

    Here is the way you can do it when building your form,

     $builder->add('field_name', 'text', array('label' => 'Field Label', 'attr' => array('class' => 'fieldClass')));
    

    You can also do it when rendering your form fields, take a look at Twig template form function reference

    {{ form_label(form.field, 'label', { 'attr': {'class': 'foo'} }) }}
    {{ form_widget(form.field, { 'attr': {'class': 'bar'} }) }}
    

    You can then add a css file in your bundle public assets and call it in your template using,

    {% block stylesheets %}
        {% parent() %} {# if you want to keep base template's stylesheets #}
        <link href="{{ asset('bundle/myBundle/css/stylesheet.css') }}" type="text/css" rel="stylesheet" />
    {% endblock %}
    

    You’ve then to make your public assets be accessible through your web/ directory.
    The best way to do it is to create symbolic links targeting your bundle public assets, you’ve then to execute

    assets:install web/ --symlink
    

    Another useful approach when you want to thoroughly customize specific form field rendering block (Twig) is to define a new form theme, here’s the documentation > Form theming in Twig.

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

Sidebar

Related Questions

I have a custom edit form made for ASPxGridView but have a big problem
EDIT: I have made a clean, new project, but still can't get it working.
I have an edit form, where the values are populated from the database. I
Say I have two fields in a new or edit form: <%= f.text_field :email
I have this function to edit all fields that come from the form and
I have a simple form where a user can add, edit, and delete people
I won't want to have edit any working sets. I just want a way
I have defined a for loop as follows which scans through a file made
EDIT Thank you all for your assistance. I have made the modifications to the
I have a form that is made up of lots of radio buttons and

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.