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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:36:45+00:00 2026-06-09T11:36:45+00:00

Symfony 2.1 Beta 4 When I am rendering my form in my twig template,

  • 0

Symfony 2.1 Beta 4

When I am rendering my form in my twig template, if I try to use form_widget or form_rest, I will receive this error – “An exception has been thrown during the rendering of a template (“Notice: Undefined index: parent in MySite/vendor/symfony/symfony/src/Symfony/Component/Form/FormView.php line 308″).” I am able to manually build the form using form_row and update the property but that does not include the csrf token.

EDIT 7/27
It looks like when I ONLY include the PropertyType form class, form_rest works fine. Once I include AddressType, I get the above error.

I am rendering a property (i.e. a house) entity with an embedded form of an address entity.

public function showAction( $property_id )
{
    $em = $this->getDoctrine()->getEntityManager();
    $property = $em->getRepository('MySystemBundle:Property')->find( $property_id );

    if( !$property ){
        throw $this->createNotFoundException('The requested property does not exist.');
    }       

    $form = $this->createForm(new PropertyType(), $property);

    $request = $this->get('request');

    if( $request->getMethod() == 'POST' ){
        $form->bind($request);

        if( $form->isValid() ){
            $em->persist($property);
            $em->flush();

            $this->get('session')->setFlash('notice', 'Your changes were saved!');
            return $this->redirect($this->generateUrl('system_propertyShow', 
                array('property_id' => $property_id)));
        }
    }

    $vars['property'] = $property;
    $vars['form'] = $form->createView();

    return $this->render('MySystemBundle:Property:show.html.twig', $vars);
}

My PropertyType form class:

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class PropertyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder->add('purchaseAmount', 'text', array('label' => 'Purchase Amount', 'required' => false))
        ->add('depositAmount', 'text', array('label' => 'Deposit Amount', 'required' => false))
        ->add('additionalCostsAmount', 'text', array('label' => 'Additional Costs', 'required' => false))
        ->add('balanceAmount', 'text', array('label' => 'Balance', 'required' => false))
        ->add('dateBalanceDue', 'datetime', array('label' => 'Balance Due', 'widget' => 'single_text', 'required' => false))
        ->add('squareFootage', 'number', array('label' => 'Square Footage', 'required' => false))
        ->add('isOccupied', 'choice', array(
            'label' => 'Is Occupied?',
            'choices' => array('1' => 'Yes', '0' => 'No'),
            'required' => false))
        ->add('address', new AddressType());
}

public function getDefaultOptions(array $options)
{
    return array('data_class' => 'MySite\Bundle\SystemBundle\Entity\Property');
}

public function getName()
{
    return 'property';
}
}

EDIT 7/27: Here is my AddressType class:

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class AddressType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add('line1', 'text', array('label' => 'Line 1'))
        ->add('line2', 'text', array('label' => 'Line 2', 'required' => false))
        ->add('line3', 'text', array('label' => 'Line 3', 'required' => false))
        ->add('city', 'text', array('label' => 'City'))
        ->add('township', 'text', array('label' => 'Township', 'required' => false))
        ->add('zipcode', 'text', array('label' => 'Zip'))
        ->add('state', new StateType());
}

public function getDefaultOptions(array $options)
{
    return array('data_class' => 'MySite\Bundle\SystemBundle\Entity\Address');
}

public function getName()
{
    return 'address';
}
}
  • 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-09T11:36:47+00:00Added an answer on June 9, 2026 at 11:36 am

    I discovered this issue discussion on Github https://github.com/symfony/symfony/issues/5121 and sure enough, disabling the twig extension in my php.ini file resolved the issue.

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

Sidebar

Related Questions

In Symfony docs they say to use this <div> {{ form_label(form.task) }} {{ form_errors(form.task)
In symfony 1.0 you can access the uncaught exception causing your custom 500 error
In symfony. . . my form looks like this <?php class ChangeMyPasswordForm extends sfForm
Symfony doc says: During each request, Symfony2 will set a global template variable app
I'm using Symfony 2.1-dev and am having problems when authenticate users using a form.
Symfony has very useful feature - view component, this is small action code and
In symfony, I call an action and I want this to return json to
I'm new to .net mvc 3. I was using PHP Symfony previously. In this
the symfony form is, 'nation' =>new sfWidgetFormChoice(array('choices' => NationPeer::getAllNation())), 'township' =>new sfWidgetFormChoice(array('choices' => TownshipPeer::getAllTownship())),
In symfony 2, one can embed a controller in a template. For example, I

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.