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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:07:22+00:00 2026-05-20T02:07:22+00:00

I am getting started with Symfony2 and I am trying to understand the Form

  • 0

I am getting started with Symfony2 and I am trying to understand the Form Component. I am looking at this page http://docs.symfony-reloaded.org/guides/forms/overview.html

And I can understand how we create form classes but what is confusing is how we actually use those forms in our controller.

$form = ContactForm::create($this->get('form.context'));

Does anyone have a more in depth explanation of the form.context portion of this code, and the actual process behind using forms within controllers?

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-05-20T02:07:23+00:00Added an answer on May 20, 2026 at 2:07 am

    form.context service is a Symfony\Component\Form\FormContext object by default. Here’s a full definition of this service:

        <service id="form.context" class="%form.context.class%">
            <argument type="collection">
                <argument key="validator" type="service" id="validator" />
                <argument key="validation_groups">%form.validation_groups%</argument>
                <argument key="field_factory" type="service" id="form.field_factory" />
                <argument key="csrf_protection">%form.csrf_protection.enabled%</argument>
                <argument key="csrf_field_name">%form.csrf_protection.field_name%</argument>
                <argument key="csrf_provider" type="service" id="form.csrf_provider" />
            </argument>
        </service>
    

    Actually it’s a very simple object that just prepare some basic options used by almost every form, ie. a validator, CSRF protection and field factory.

    In fact the code you’ve posted is equivalent of:

    $form = new \Symfony\Components\Form\Form(null, array(
        'validator' => $this->get('validator'),
        'validation_groups' => ...
        ...
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just getting started with Powershell and have a quick question. Trying to run this
I am just getting started with symfony and am trying to build the database
Im just getting started on this whole WPF thing, and need to understand some
I'm getting started with Paperclip and can't figure out something: why isn't this form
Just getting started with Linq to SQL so forgive the newbie question. I'm trying
I am just getting started with expression trees so I hope this makes sense.
The Getting Started Rails Guide kind of glosses over this part since it doesn't
Just getting started with OpenFrameworks and I'm trying to do something that should be
I am just getting started with Rails 3 and I do not quite understand
I'm looking at getting started with simple mobile app development. Corona SDK looks like

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.