Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] Reverted PR #1758. #1769

Merged
merged 1 commit into from Jul 22, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

This file was deleted.

Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
use Symfony\Component\Form\Extension\Core\EventListener\ObjectFactoryListener;

class CollectionType extends AbstractType
{
Expand All @@ -30,13 +29,6 @@ public function buildForm(FormBuilder $builder, array $options)
$builder->setAttribute('prototype', $prototype->getForm());
}

$dataClass = isset($options['options']['data_class']) ? $options['options']['data_class'] : null;
if ($dataClass || $options['class']) {
$class = $dataClass ? $dataClass : $options['class'];
$listener = new ObjectFactoryListener($class);
$builder->addEventSubscriber($listener);
}

$listener = new ResizeFormListener(
$builder->getFormFactory(),
$options['type'],
Expand Down Expand Up @@ -88,7 +80,6 @@ public function getDefaultOptions(array $options)
'prototype' => true,
'type' => 'text',
'options' => array(),
'class' => null,
);
}

Expand Down
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Form\CollectionForm;
use Symfony\Component\Form\Form;
use Symfony\Tests\Component\Form\Fixtures\AuthorType;

class CollectionFormTest extends TypeTestCase
{
Expand Down Expand Up @@ -143,42 +142,6 @@ public function testPrototypeMultipartPropagation()
$this->assertTrue($form->createView()->get('multipart'));
}

public function testObjectsAreCreated()
{
$form = $this->factory
->create('collection', null, array(
'type' => new AuthorType(),
'allow_add' => true,
'class' => 'Symfony\Tests\Component\Form\Fixtures\Author',
))
;

$data = array(array('last_name' => 'Foo'), array('last_name' => 'Bar'));
$form->bind($data);
$bound = $form->getData();
$this->assertEquals(2, count($bound));
$this->assertInstanceOf('Symfony\Tests\Component\Form\Fixtures\Author', $bound[0]);
$this->assertInstanceOf('Symfony\Tests\Component\Form\Fixtures\Author', $bound[1]);
$this->assertEquals('Foo', $bound[0]->getLastName());
$this->assertEquals('Bar', $bound[1]->getLastName());
}

public function testObjectsAreCreatedWithDataClassOption()
{
$form = $this->factory
->create('collection', null, array(
'type' => new AuthorType(),
'allow_add' => true,
'options' => array('data_class' => 'Symfony\Tests\Component\Form\Fixtures\Author')
))
;

$data = array(array('last_name' => 'Foo'), array('last_name' => 'Bar'));
$form->bind($data);
$bound = $form->getData();
$this->assertInstanceOf('Symfony\Tests\Component\Form\Fixtures\Author', $bound[0]);
}

public function testGetDataDoesNotContainsProtypeNameBeforeDataAreSet()
{
$form = $this->factory->create('collection', array(), array(
Expand Down
24 changes: 0 additions & 24 deletions tests/Symfony/Tests/Component/Form/Fixtures/AuthorType.php

This file was deleted.