Skip to content

Commit

Permalink
Merge pull request sonata-project#3709 from WouterJ/fix-sf-3
Browse files Browse the repository at this point in the history
Fix Symfony 3 support in datagrid filter (and another bug)
  • Loading branch information
greg0ire committed Apr 19, 2016
2 parents a107e8f + 7f638a4 commit 4a8a10b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 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', '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);
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', 'text');
return $this->getOption('field_type', 'Symfony\Component\Form\Extension\Core\Type\TextType');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/CRUD/base_show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ file that was distributed with this source code.
{% endfor %}
</div>
</div>
{% else %}
{% elseif admin.showtabs is iterable %}
{{ show_helper.render_groups(admin, object, elements, admin.showtabs.default.groups, has_tab) }}
{% endif %}

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('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(
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('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());

Expand Down

0 comments on commit 4a8a10b

Please sign in to comment.