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 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

yikes i have forgotten but am following: http://www.symfony-project.org/getting-started/1_4/en/03-Symfony-Installation i have a jobeet directory and
I am getting started with Symfony 2 & I am following this tutorial. Now,
I am just getting started with symfony and am trying to build the database
Just getting started with Powershell and have a quick question. Trying to run this
I'm just getting started with Threads in Java so this might be a basic
I'm just getting started on Sitecore DMS 2.0, and not sure if I understand
Getting started with python. I am trying to implement positional index using nested dictionary.
I'm just getting started on Prototypes, and I'm trying to test different things on
Just getting started with OpenFrameworks and I'm trying to do something that should be
FYI I'm just getting started with Symfony, with that said... What advantage would there

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.