Skip to content

Commit

Permalink
Handle Symfony BC for Datagrid hidden types (#4021)
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh authored Jul 27, 2016
1 parent 726b038 commit cd54b2a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Datagrid/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ public function buildPager()
$this->formBuilder->add($filter->getFormName(), $type, $options);
}

$this->formBuilder->add('_sort_by', 'hidden');
// NEXT_MAJOR: Remove BC trick when bumping Symfony requirement to 2.8+
$hiddenType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
: 'hidden';

$this->formBuilder->add('_sort_by', $hiddenType);
$this->formBuilder->get('_sort_by')->addViewTransformer(new CallbackTransformer(
function ($value) {
return $value;
Expand All @@ -136,9 +141,9 @@ function ($value) {
}
));

$this->formBuilder->add('_sort_order', 'hidden');
$this->formBuilder->add('_page', 'hidden');
$this->formBuilder->add('_per_page', 'hidden');
$this->formBuilder->add('_sort_order', $hiddenType);
$this->formBuilder->add('_page', $hiddenType);
$this->formBuilder->add('_per_page', $hiddenType);

$this->form = $this->formBuilder->getForm();
$this->form->submit($this->values);
Expand Down

0 comments on commit cd54b2a

Please sign in to comment.