我在一种形式中使用了两个实体,ContentType 在EstablishmentType 中。如果我只使用“经典”字段类型,我不会出错。但是,当我在 ContentType 中添加字段 'translations' 和 'a2lix_translations_gedmo' 作为类型时,它返回一个 ReflectionException“类不存在”。
A2lix 的翻译在其他实体中运行良好。
作为任何人的想法?
下面的代码:
建立类型.php
namespace Demo\FoundationBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class EstablishmentType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('content', new ContentType(),array(
'data_class'=>null
))
->add('translations', 'a2lix_translations_gedmo',array(
'translatable_class' => "Demo\FoundationBundle\Entity\Establishment",
))
->add('category','entity',array(
'class'=>'Demo\FoundationBundle\Entity\Category',
"required"=>true,
'label'=>'Categorie'
))
->add('file','file')
->add('participationLevel','number',array(
'label'=>'Taux de participation'
))
;
}
ContentType.php 命名空间Demo\FoundationBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class ContentType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('type','choice',
array(
'choices'=>array(
'text'=>'Texte',
'highlight'=>'Mise en avant'
),
'required'=>false
))
->add('translations', 'a2lix_translations_gedmo',array(
'translatable_class' => "Demo\FoundationBundle\Entity\Content",
))
->add('class','text',array(
'label'=>'Classe css',
'required'=>false
))
->add('column_nb','number',array(
'label'=>'Nombre de colonnes',
'required'=>false
))
;
}
堆栈跟踪
ReflectionException: Class does not exist
at n/a
in /var/www/html/Demo/app/cache/dev/classes.php line 6969
at ReflectionClass->__construct('')
in /var/www/html/Demo/app/cache/dev/classes.php line 6969
at Doctrine\Common\Persistence\AbstractManagerRegistry->getManagerForClass(null)
in /var/www/html/Demo/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/GedmoTranslationForm.php line 45
at A2lix\TranslationFormBundle\TranslationForm\GedmoTranslationForm->getGedmoConfig(null)
in /var/www/html/Demo/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/GedmoTranslationForm.php line 67
at A2lix\TranslationFormBundle\TranslationForm\GedmoTranslationForm->getTranslatableFields(null)
in /var/www/html/Demo/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/TranslationForm.php line 48
at A2lix\TranslationFormBundle\TranslationForm\TranslationForm->getChildrenOptions(null, array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'required' => true, 'read_only' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'virtual' => null, 'compound' => true, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_provider' => object(CsrfTokenManager), 'intention' => null, 'locales' => array('fr', 'de', 'en'), 'fields' => array(), 'attr' => array(), 'data_class' => null, 'empty_data' => object(Closure), 'error_bubbling' => true, 'label_attr' => array(), 'inherit_data' => false, 'validation_groups' => null, 'constraints' => array(), 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'translatable_class' => 'Demo\FoundationBundle\Entity\Content'))
in /var/www/html/Demo/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/EventListener/GedmoTranslationsListener.php line 45
at A2lix\TranslationFormBundle\Form\EventListener\GedmoTranslationsListener->preSetData(object(FormEvent), 'form.pre_set_data', object(EventDispatcher))
in line
at call_user_func(array(object(GedmoTranslationsListener), 'preSetData'), object(FormEvent), 'form.pre_set_data', object(EventDispatcher))
in /var/www/html/Demo/app/cache/dev/classes.php line 1834
at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(array(object(GedmoTranslationsListener), 'preSetData')), 'form.pre_set_data', object(FormEvent))
in /var/www/html/Demo/app/cache/dev/classes.php line 1763
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('form.pre_set_data', object(FormEvent))
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php line 43
at Symfony\Component\EventDispatcher\ImmutableEventDispatcher->dispatch('form.pre_set_data', object(FormEvent))
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 342
at Symfony\Component\Form\Form->setData(null)
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php line 57
at Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper->mapDataToForms(object(ArrayCollection), object(RecursiveIteratorIterator))
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 396
at Symfony\Component\Form\Form->setData(object(ArrayCollection))
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php line 57
at Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper->mapDataToForms(object(Establishment), object(RecursiveIteratorIterator))
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 396
at Symfony\Component\Form\Form->setData(object(Establishment))
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 488
at Symfony\Component\Form\Form->initialize()
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php line 226
at Symfony\Component\Form\FormBuilder->getForm()
in /var/www/html/Demo/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php line 39
at Symfony\Component\Form\FormFactory->create(object(EstablishmentType), object(Establishment))
in /var/www/html/Demo/src/Demo/AdminBundle/Controller/Est/NewController.php line 17
at Demo\AdminBundle\Controller\Est\NewController->indexAction()
in line
at call_user_func_array(array(object(NewController), 'indexAction'), array())
in /var/www/html/Demo/app/bootstrap.php.cache line 3109
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in /var/www/html/Demo/app/bootstrap.php.cache line 3071
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in /var/www/html/Demo/app/bootstrap.php.cache line 3222
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in /var/www/html/Demo/app/bootstrap.php.cache line 2444
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /var/www/html/Demo/web/app_dev.php line 28