Skip to content

Commit 86a48f1

Browse files
committed
Fixing form type compatibility.
1 parent 0ee0e63 commit 86a48f1

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

Form/Type/ExpandedMTMType.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use abdielcs\ExpandedCollectionBundle\Form\DataTransformer\MiddleClassTransformer;
1515
use Symfony\Component\Form\AbstractType;
1616
use Symfony\Component\Form\FormBuilderInterface;
17+
use Symfony\Component\OptionsResolver\OptionsResolver;
1718
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
1819

1920
/**
@@ -34,7 +35,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3435

3536
public function getParent()
3637
{
37-
return 'expanded_otm';
38+
if (Kernel::MAJOR_VERSION > 2) {
39+
return ExpandedOTMType::class ;
40+
} else {
41+
return 'expanded_otm';
42+
}
3843
}
3944

4045
public function getName()
@@ -51,6 +56,11 @@ public function getBlockPrefix()
5156
* {@inheritdoc}
5257
*/
5358
public function setDefaultOptions(OptionsResolverInterface $resolver)
59+
{
60+
$this->configureOptions($resolver);
61+
}
62+
63+
public function configureOptions(OptionsResolver $resolver)
5464
{
5565
$resolver->setRequired(array(
5666
'middle_class'

Form/Type/ExpandedOTMType.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ class ExpandedOTMType extends AbstractType
2525
{
2626
public function getParent()
2727
{
28-
return 'entity';
28+
if (Kernel::MAJOR_VERSION > 2) {
29+
return EntityType::class;
30+
} else {
31+
return 'entity';
32+
}
2933
}
3034

3135
public function getName()
@@ -42,6 +46,11 @@ public function getBlockPrefix()
4246
* {@inheritdoc}
4347
*/
4448
public function setDefaultOptions(OptionsResolverInterface $resolver)
49+
{
50+
$this->configureOptions($resolver);
51+
}
52+
53+
public function configureOptions(OptionsResolver $resolver)
4554
{
4655
$resolver->setDefaults(array(
4756
'multiple' => true,

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ options setted to true. Read more about [entity type field](http://symfony.com/d
1919
Installation
2020
------------
2121

22-
### Step 1: Include the bundle in your require section of composer.json and do a composer update.
22+
### Step 1: Include the bundle in your require section of composer.json
2323

2424
```json
2525
"require": {
@@ -28,7 +28,7 @@ Installation
2828
},
2929
```
3030

31-
This command requires you to have Composer installed globally, as explained
31+
Then do a composer update. This command requires you to have Composer installed globally, as explained
3232
in the [Composer documentation](https://getcomposer.org/doc/00-intro.md).
3333

3434
### Step 2: Enable the Bundle

Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
tags:
99
- { name: form.type, alias: 'expanded_otm' }
1010

11-
expanded_otm.service:
11+
expanded_mtm.service:
1212
class: "%expanded_mtm.form%"
1313
tags:
1414
- { name: form.type, alias: 'expanded_mtm' }

0 commit comments

Comments
 (0)