this is my form:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class JoseType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('nombre')
->add('apellido')
->add('edad')
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Jose'
));
}
/**
* @return string
*/
public function getName()
{
return 'appbundle_jose';
}
}
And this is my test:
use AppBundle\Form\JoseType;
use Symfony\Component\Form\Test\TypeTestCase;
class ProjectTypeTest extends TypeTestCase
{
public function testForm()
{
$form = $this->factory->create(JoseType::class);
}
}
To running test receive this:
Symfony\Component\Form\Exception\InvalidArgumentException: Could not load type "AppBundle\Form\JoseType"
I have symfony 2.6.13.
In symfony 3.2 works, but 2.6 doesn't work, Why? ... any idea?
Aucun commentaire:
Enregistrer un commentaire