since "Symfony\Component\OptionsResolver\OptionsResolverInterface" is deprecated in SF2.6 I tried to update my FormTypes:
<?php
namespace Xxx\XxxBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @uses Symfony\Component\Form\AbstractType
* @uses Symfony\Component\Form\FormBuilderInterface
* @uses Symfony\Component\OptionsResolver\OptionsResolver
* @package Xxx\XxxBundle\Form\Type
*/
class XxxType extends AbstractType
{
/**
* default form builder
*
* @param \Symfony\Component\Form\FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('xxx', 'text') // ...
}
/**
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*/
public function setDefaultOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'data_class' => 'xxx',
'option1' => [],
'option2' => 3,
'intention' => 'xxx',
'cascade_validation' => true
]
);
}
/**
* @return string
*/
public function getName()
{
return 'xxx';
}
}
The problem is that AbstractType still expects "setDefaultOptions(OptionsResolverInterface $resolver)" instead of "OptionsResolover"
Declaration must be compatible with FormTypeInterface->setDefaultOptions(resolver : \Symfony\Component\OptionsResolver\OptionsResolverInterface)
Is there anything im missing here?
Thanks ;)
EDIT
Changed my controller call from
$form = $this->createForm(
new XxxType(),
$xxxEntity,
[
'option1' => $array
]
);
to
$form = $this->createForm(
new XxxType([
'option1' => $array
]),
$xxxEntity
);
and adding this to the FormType:
protected $option1;
public function __construct($options)
{
$this->option1 = $options['option1'];
}
did it, without adding form options / changing defaults now. Thanks