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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:52:55+00:00 2026-05-31T14:52:55+00:00

I am following the tutorial from Symfony2 on how to use form classes. I

  • 0

I am following the tutorial from Symfony2 on how to use form classes.

I am doing something wrong, because when I use the following example code:

// src/Acme/TaskBundle/Controller/DefaultController.php

// add this new use statement at the top of the class
use Acme\TaskBundle\Form\Type\TaskType;

public function newAction()
{
    //$task = // ... ???
    $form = $this->createForm(new TaskType(), $task);

// ...
}

…I receive the following error:

Notice: Undefined variable: task

I understand that $task has not yet been defined properly. Can anyone explain to me how I should define it? I tried creating it as entity, as formType, as undefined variable, but all to no luck.

Cheers

  • 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-31T14:52:57+00:00Added an answer on May 31, 2026 at 2:52 pm

    If you follow the tutorial from the first then you should have created a Task entity in Acme\TaskBundle\Entity namespace. So your controller would be,

    // src/Acme/TaskBundle/Controller/DefaultController.php
    
    // add this new use statement at the top of the class
    use Acme\TaskBundle\Form\Type\TaskType;
    use Acme\TaskBundle\Entity\Task;
    
    public function newAction()
    {
        $task = new Task();
        $form = $this->createForm(new TaskType(), $task);
    
    // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following this tutorial from MSDN. There's something I saw in the code
I'm following the tutorial from Ryan B, but I got something wrong when trying
I'm following a tutorial on how to use Interface Builder from Chapter 2 of
Here is my following tutorial code from Learning PHP MYSQL and Javascript by OReilly.
I am following GWT tutorial from code.google.com. I build an application using webAppCreator &
I use the tutorial from the following to create MSP file. http://www.codeproject.com/KB/install/dotnetpatching.aspx?fid=209224&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2567089 However, I
I am following Java Hibernate tutorial example from YouTube. Everything looks great until I
I managed to get authentication to work by following the tutorial from this page
I'm following the kernel tutorial from here im having problems compiling my files. i
I'm new to NHibernate... I have been following this NHibernate Tutorial from Gabriel Schenker

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.