Closed
Description
I think, I found bug in Form functional:
<?php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class TestForm extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// Ok
$builder->add($builder->create('text_test', 'text'));
// Error
$builder->add($builder->create('button_test', 'submit'));
}
public function getName()
{
return 'test_form';
}
}
Error:
Expected argument of type "string, integer or Symfony\Component\Form\FormBuilder", "Symfony\Component\Form\SubmitButtonBuilder" given
It is because method \Symfony\Component\Form\FormBuilder::add() contains check for instanceof self and any button-like type inherited from ButtonBuilder.
Both builders (FormBuilder and ButtonBuilder) have interface \Symfony\Component\Form\FormBuilderInterface.
So, if we change check of $child in method FormBuilder::add() to instanceof \Symfony\Component\Form\FormBuilderInterface all will be fine.
I checked this situation on 2.3 and 2.6 versions. Both have a bug.
Metadata
Metadata
Assignees
Labels
No labels