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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:39:13+00:00 2026-06-17T05:39:13+00:00

I don’t use any ORM for entities. This form is built for sending email

  • 0

I don’t use any ORM for entities. This form is built for sending email only.

In my Controller I have this:

    $builder = $this->myHelper
        ->createBuilder('form', null)

        ->add('my_group', 'collection', array(
        'type' => 'text',
        'label' => 'mylabel'
    ));

    $builder->get('my_group')->add('first_node', 'text');
    $builder->get('my_group')->add('second_node', 'text');

    return $builder->getForm();

The form is rendered OK – with additional input fields as expected. But when it comes to binding request to form in my post-data handling action – my_group field comes empty (even due to fact that this field is posted in 'form' array):

// var_dump($request->get('form'));die;
array
 'my_group' => 
   array
     'first_node' => string 'asdasd' (length=3)
     'second_node' => string 'asdasda' (length=3)

When I bind request to form, I have null in my_group collection field (all other inputs are OK).

$form->bindRequest($request);
$formData = $form->getData();
var_dump($formData);die; // Outputs my_group => null

What am I doing wrong?


UPDATE 1

Part of Twig template (requested by Max):

{% for field in form.children if 'hidden' not in field.vars.types %}
    ...
    {% elseif 'collection' in field.vars.types %}
        <th>{{ form_label(field) }}</th>
        <td>
            {% for collection_field in field %}
                {{ form_widget(collection_field) }}
            {% endfor %}
        </td>
    {% else %}
    ...
{% endfor %}
  • 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-17T05:39:15+00:00Added an answer on June 17, 2026 at 5:39 am

    My problem was solved, when I defined FormType for needed collection:

    class MyType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options)
        {
            $builder->add('first_node', 'text');
            $builder->add('second_node', 'text');
        }
    
        public function getDefaultOptions(array $options)
        {
            return array();
        }
    
        public function getName()
        {
            return 'mytype';
        }
    }
    

    Then I used it in builder:

    $builder = $this->myHelper
        ->createBuilder('form', null)
    
        ->add('my_group', new MyType(), array(
        'label' => 'mylabel'
    ));
    
    
    return $builder->getForm();
    

    After this data was bound to form correctly.

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

Sidebar

Related Questions

Don't be afraid to use any technical jargon or low-level explanations for things, please.
Don't overthink this - there's a very commonly used term and I ... have
Don't think my virtualhost is working correctly. This is what I have inside of
Don't know why this is happening, but after submitting a form via JS (using
Don't know if this is possible, but I have some code like this: val
Don't know if this has been answered before. Have custom routes to users. If
don't understand: in my controller: @json = User.all.to_gmaps4rails do |user| \Title\: \#{user.email}\ end in
Don't ask me why but i can't use this method because I need to
Don't know why but I can't find a solution to this. I have 3
don't know better title for this, but here's my code. I have class user

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.