From 7f638a48b22d84b24e856903fdfd5e79e447c9ec Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 9 Apr 2016 13:38:04 +0200 Subject: [PATCH] Add Symfony 3 support in datagrid --- Datagrid/Datagrid.php | 8 ++++---- Filter/Filter.php | 2 +- Resources/views/CRUD/base_show.html.twig | 2 +- Tests/Datagrid/DatagridMapperTest.php | 2 +- Tests/Filter/FilterTest.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Datagrid/Datagrid.php b/Datagrid/Datagrid.php index 0f12dbc6b7..c7a71778cb 100644 --- a/Datagrid/Datagrid.php +++ b/Datagrid/Datagrid.php @@ -126,15 +126,15 @@ public function buildPager() $this->formBuilder->add($filter->getFormName(), $type, $options); } - $this->formBuilder->add('_sort_by', 'hidden'); + $this->formBuilder->add('_sort_by', 'Symfony\Component\Form\Extension\Core\Type\HiddenType'); $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', 'hidden'); - $this->formBuilder->add('_page', 'hidden'); - $this->formBuilder->add('_per_page', 'hidden'); + $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->form = $this->formBuilder->getForm(); $this->form->submit($this->values); diff --git a/Filter/Filter.php b/Filter/Filter.php index b0f25ce1bb..a60144ec4e 100644 --- a/Filter/Filter.php +++ b/Filter/Filter.php @@ -95,7 +95,7 @@ public function setOption($name, $value) */ public function getFieldType() { - return $this->getOption('field_type', 'text'); + return $this->getOption('field_type', 'Symfony\Component\Form\Extension\Core\Type\TextType'); } /** diff --git a/Resources/views/CRUD/base_show.html.twig b/Resources/views/CRUD/base_show.html.twig index 471d1ddd2f..598ebcb748 100644 --- a/Resources/views/CRUD/base_show.html.twig +++ b/Resources/views/CRUD/base_show.html.twig @@ -61,7 +61,7 @@ file that was distributed with this source code. {% endfor %} - {% else %} + {% elseif admin.showtabs is iterable %} {{ show_helper.render_groups(admin, object, elements, admin.showtabs.default.groups, has_tab) }} {% endif %} diff --git a/Tests/Datagrid/DatagridMapperTest.php b/Tests/Datagrid/DatagridMapperTest.php index 7b8fe54b8c..3d4b007e61 100644 --- a/Tests/Datagrid/DatagridMapperTest.php +++ b/Tests/Datagrid/DatagridMapperTest.php @@ -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('text', $filter->getFieldType()); + $this->assertSame('Symfony\Component\Form\Extension\Core\Type\TextType', $filter->getFieldType()); $this->assertSame('fooLabel', $filter->getLabel()); $this->assertSame(array('required' => false), $filter->getFieldOptions()); $this->assertSame(array( diff --git a/Tests/Filter/FilterTest.php b/Tests/Filter/FilterTest.php index deaf4479bc..c14e3dc860 100644 --- a/Tests/Filter/FilterTest.php +++ b/Tests/Filter/FilterTest.php @@ -19,7 +19,7 @@ public function testFilter() { $filter = new FooFilter(); - $this->assertSame('text', $filter->getFieldType()); + $this->assertSame('Symfony\Component\Form\Extension\Core\Type\TextType', $filter->getFieldType()); $this->assertSame(array('required' => false), $filter->getFieldOptions()); $this->assertNull($filter->getLabel());