Skip to content

Commit

Permalink
Merge pull request #8 from XitasoChris/update-2.8
Browse files Browse the repository at this point in the history
Update to fix deprecation messages introduced in 2.8
  • Loading branch information
colinfrei authored Jan 9, 2017
2 parents 04fcdd3 + 6ec83a4 commit b08a2e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 47 deletions.
20 changes: 0 additions & 20 deletions DependencyInjection/ColinFreiBitFieldTypeExtension.php

This file was deleted.

25 changes: 15 additions & 10 deletions Form/Type/BitfieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,36 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

use ColinFrei\BitFieldTypeBundle\Form\DataTransformer\BitfieldToArrayTransformer;

class BitfieldType extends AbstractType
{
public function getDefaultOptions(array $options)
/**
* {@inheritDoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
return array(
$resolver->setDefaults(array(
'expanded' => true,
'multiple' => true,
);
));
}

/**
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addModelTransformer(new BitfieldToArrayTransformer());
}

/**
* {@inheritDoc}
*/
public function getParent()
{
return new ChoiceType();
return ChoiceType::class;
}

public function getName()
{
return 'bitfield';
}
}
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ Register the bundle in your app/AppKernel.php file, by adding this line in the `

## Usage

Use the type `bitfield` when adding fields to the form, and pass in an array of options, like the type line in this example from the [Symfony documentation](http://symfony.com/doc/current/book/forms.html#building-the-form):
Use the `BitfieldType` class when adding fields to the form, and pass in an array of options, like the type line in this example from the [Symfony documentation](http://symfony.com/doc/current/book/forms.html#building-the-form):

use ColinFrei\BitFieldTypeBundle\Form\Type\BitfieldType;

$form = $this->createFormBuilder($task)
->add('task', 'text')
->add('dueDate', 'date')
->add('type', 'bitfield', array(
'choices' => array('1' => 'Annoying', '2' => 'Fun', '4' => 'Cool', '8' => 'Takes a while')
->add('type', BitfieldType::class, array(
'choices' => array('Annoying' => '1', 'Fun' => '2', 'Cool' => '4', 'Takes a while' => '8'),
'choices_as_values' => true
)
->getForm();
13 changes: 0 additions & 13 deletions Resources/config/services.xml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Adds a bitfield type to use in Symfony Forms",
"license": "MIT",
"require": {
"symfony/symfony": "~2.6"
"symfony/symfony": "~2.7"
},
"authors": [
{
Expand Down

0 comments on commit b08a2e9

Please # to comment.