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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:57:59+00:00 2026-06-14T13:57:59+00:00

How to reproduce this: 1. Create a collection of some type <?php $builder->add(‘foo’, ‘collection’,

  • 0

How to reproduce this:

1. Create a collection of some type

<?php

$builder->add('foo', 'collection', array(
  'type'            => new BarType(),
  'allow_add'       => true,
  'allow_delete'    => true,
  'by_reference'    => false,
  'prototype'       => true,
  'prototype_name'  => 'this_is_prototype',
  'options'         => array(
      'data_class' => 'Acme\FooBundle\Entity\Bar'
    ),
));

2. Create BarType

<?php 

class BarType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        var_dump(array(
            $builder->getForm()->getName() => $builder->hasParent()
        ));
        $builder->add('bar', 'text'); 
        // this actually is not relevant, just adding anything
        // so that bar form is not empty
    }
}

Result of var_dump()

If our collection holds 3 Bar objects then the result will be:

array (size=1)
  'this_is_prototype' => boolean true

array (size=1)
  0 => boolean false

array (size=1)
  1 => boolean false

array (size=1)
  2 => boolean false

Conclusion

In buildForm $builder->getParent() will return parent builder only for prototype.

Issue / question

I need to access parent form to get some parameters. Why is parent dropped for existing collection elements? Is there any workaround?

Related github issue

  • 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-14T13:58:00+00:00Added an answer on June 14, 2026 at 1:58 pm

    bschussek:

    The answer is that at the point when buildForm() is called, the parent
    is not yet known (remember we are just building the form). So a form
    should not depend on its parent. Instead, you should add options to
    your type and set these options from the parent to modify the behavior
    of the child.

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

Sidebar

Related Questions

Does anyone know how I can reproduce this SQL Query as a SubSonic Query?
is there any way I can reproduce this ruby function: def Password.hash(password,salt) Digest::SHA512.hexdigest(#{password}:#{salt}) end
I'm trying to reproduce the heatmap presented on this blog by following their tutorial,
I am trying to reproduce a simple jquery slider example that works on this
I'm trying to reproduce the effect our friend @Dr. Molle told us on this
Here's the simple test to reproduce the issue, this is the single class in
Starting from Android 3.2 I have this strange problem. It's very easy to reproduce:
Just to explain more about the context, this is how to reproduce: Delphi 7
Can someone write a PHP script that reproduces the functionality of this linux shell
Ok steps to reproduce this: prompt> rails test_app prompt> cd test_app prompt> script/generate model

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.