Skip to content

Commit

Permalink
Use form type names instead of FQCN (reverts #3709) (#3753)
Browse files Browse the repository at this point in the history
My previously merged change turned out to not fix, but break the admin
panel. While there can be no garantee that this commit "fixes" anything
instead of breaking it, the change of getting a working admin panel will
be significantly increased after this PR. This because it reverts things
back to the state they were for the past 5 years (without any bug report
about it being broken).
  • Loading branch information
wouterj authored and soullivaneuh committed May 1, 2016
1 parent 1b9f421 commit 5009ab9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Datagrid/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ public function buildPager()
$this->formBuilder->add($filter->getFormName(), $type, $options);
}

$this->formBuilder->add('_sort_by', 'Symfony\Component\Form\Extension\Core\Type\HiddenType');
$this->formBuilder->add('_sort_by', 'hidden');
$this->formBuilder->get('_sort_by')->addViewTransformer(new CallbackTransformer(
function ($value) { return $value; },
function ($value) { return $value instanceof FieldDescriptionInterface ? $value->getName() : $value; }
));

$this->formBuilder->add('_sort_order', 'Symfony\Component\Form\Extension\Core\Type\HiddenType');
$this->formBuilder->add('_page', 'Symfony\Component\Form\Extension\Core\Type\HiddenType');
$this->formBuilder->add('_per_page', 'Symfony\Component\Form\Extension\Core\Type\HiddenType');
$this->formBuilder->add('_sort_order', 'hidden');
$this->formBuilder->add('_page', 'hidden');
$this->formBuilder->add('_per_page', 'hidden');

$this->form = $this->formBuilder->getForm();
$this->form->submit($this->values);
Expand Down
2 changes: 1 addition & 1 deletion Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function setOption($name, $value)
*/
public function getFieldType()
{
return $this->getOption('field_type', 'Symfony\Component\Form\Extension\Core\Type\TextType');
return $this->getOption('field_type', 'text');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Datagrid/DatagridMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testGet()
$this->assertInstanceOf('Sonata\AdminBundle\Filter\FilterInterface', $filter);
$this->assertSame('foo.name', $filter->getName());
$this->assertSame('foo__name', $filter->getFormName());
$this->assertSame('Symfony\Component\Form\Extension\Core\Type\TextType', $filter->getFieldType());
$this->assertSame('text', $filter->getFieldType());
$this->assertSame('fooLabel', $filter->getLabel());
$this->assertSame(array('required' => false), $filter->getFieldOptions());
$this->assertSame(array(
Expand Down
2 changes: 1 addition & 1 deletion Tests/Filter/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testFilter()
{
$filter = new FooFilter();

$this->assertSame('Symfony\Component\Form\Extension\Core\Type\TextType', $filter->getFieldType());
$this->assertSame('text', $filter->getFieldType());
$this->assertSame(array('required' => false), $filter->getFieldOptions());
$this->assertNull($filter->getLabel());

Expand Down

0 comments on commit 5009ab9

Please sign in to comment.