Skip to content

Commit

Permalink
Used classname in form type name (sonata-project#4118)
Browse files Browse the repository at this point in the history
  • Loading branch information
deguif authored and OskarStark committed Sep 2, 2016
1 parent 280c412 commit 1541dd8
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Form/Type/ChoiceFieldMaskType.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return 'choice';
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice';
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/Filter/DateRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add('type', 'choice', $choiceOptions)
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice', $choiceOptions)
->add('value', $options['field_type'], $options['field_options'])
;
}
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/Filter/DateTimeRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add('type', 'choice', $choiceOptions)
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice', $choiceOptions)
->add('value', $options['field_type'], $options['field_options'])
;
}
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/Filter/DateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add('type', 'choice', $choiceOptions)
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice', $choiceOptions)
->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options']))
;
}
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/Filter/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add('type', 'choice', $choiceOptions)
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice', $choiceOptions)
->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options']))
;
}
Expand Down
8 changes: 6 additions & 2 deletions Form/Type/Filter/DefaultType.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'operator_type' => 'hidden',
'operator_type' => method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
: 'hidden', // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
'operator_options' => array(),
'field_type' => 'text',
'field_type' => method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\TextType'
: 'text', // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
'field_options' => array(),
));
}
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/Filter/NumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add('type', 'choice', $choiceOptions)
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
->add('type', method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice', $choiceOptions)
->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options']))
;
}
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/ModelHiddenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return 'hidden';
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
: 'hidden';
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/ModelListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return 'text';
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\TextType'
: 'text';
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/ModelReferenceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return 'text';
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\TextType'
: 'text';
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/ModelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return 'choice';
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice';
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Tests/Form/Type/ChoiceFieldMaskTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function testGetName()
public function testGetParent()
{
$type = new ChoiceFieldMaskType();
$this->assertSame('choice', $type->getParent());
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
$this->assertSame(method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
: 'choice', $type->getParent());
}
}
5 changes: 4 additions & 1 deletion Tests/Form/Type/ModelHiddenTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function testGetName()
public function testGetParent()
{
$type = new ModelHiddenType();
$this->assertSame('hidden', $type->getParent());
// NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
$this->assertSame(method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\HiddenType'
: 'hidden', $type->getParent());
}
}

0 comments on commit 1541dd8

Please sign in to comment.