Я мигрирую на веб -сайте с Symfony 2.6 на 3.4, и у меня есть некоторые проблемы с регистрационными формами и Fosuserbundle. У меня появляется эта ошибка. Я проверил его код и увидел, что под его SRC \ Pix \ UserBundle \ Form \ RegistrationFormType.php, но есть еще одна папка «тип» с файлом с тем же именем: «RegistrationFormType.php» < /p>
Я пробовал изменить форму с новейшим стилем, взятым оттуда: оттуда: < /p>
Я пробовал изменить форму новейшим стилем: < /p>
https://github.com/symfony/symfony/blob ... .8.md#form
app/config/config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: Pix\UserBundle\Entity\User
registration:
form:
type: Pix\UserBundle\Form\RegistrationFormType
validation_groups: [ pix_registration, Default ]
Файл службы в Pix/Userbundle/Resources/config/services.yml
services:
pix_userbundle_registrationformtype:
class: Pix\UserBundle\Form\Type\RegistrationFormType
arguments: ["%fos_user.model.user.class%"]
tags:
- { name: form.type }
pix/userbundle/form/registrationformtype.php:
namespace Pix\UserBundle\Form;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class RegistrationFormType extends AbstractType
{
public function __construct($class = "User")
{
parent::__construct($class);
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('username', 'text', array(
'label' => 'Pseudonyme',
))
->add('email', 'text', array(
'label' => 'Adresse mail',
))
->add('plainPassword', 'repeated', array(
'type' => 'password',
'first_options' => array('label' => 'Mot de passe'),
'second_options' => array('label' => 'Confirmation'),
'invalid_message' => 'Mot de passe incorrect',
))
->add('enabled', 'checkbox', array(
'label' => "Activé",
'required' => false
))
->add('firstname', 'text', array(
'label' => 'Prénom',
))
->add('lastname', 'text', array(
'label' => 'Nom',
))
->add('phone', 'text', array(
'label' => 'Téléphone',
))
->add('street', 'text', array(
'label' => "Adresse postale",
'required' => true
))
->add('number', 'text', array(
'label' => "Numéro d'adresse",
'required' => true
))
->add('npa', 'text', array(
'label' => "Code postal",
'required' => true
))
->add('city', 'text', array(
'label' => "Ville",
'required' => true
))
->add('state', 'text', array(
'label' => "Canton",
'required' => true
))
->add('country', 'text', array(
'label' => "Pays",
'required' => true
))
->add('latitude', 'text', array(
'label' => "Latitude",
'required' => true
))
->add('longitude', 'text', array(
'label' => "Longitude",
'required' => true
))
->add('code', 'text', array(
'label' => 'Code de parrainage',
'required' => false
))
->add('pro', 'choice', array(
'label' => "Professionel",
'choices' => array(
true => 'Oui',
false => 'Non',
),
'expanded' => false,
'multiple' => false,
'required' => true
))
->add('iban', 'text', array(
'label' => 'IBAN',
'required' => false
))
->add('distance', 'text', array(
'label' => "Rayon d'intervention",
'required' => false
))
->add('picture', new DocumentType(), array('required' => false))
->add('curriculum', new DocumentType(), array('required' => false))
->add('motivation', new DocumentType(), array('required' => false))
->add('document', new DocumentType(), array('required' => false))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Pix\UserBundle\Entity\User'
));
}
public function getParent()
{
return BaseRegistrationFormType::class;
}
public function getBlockPrefix()
{
return 'pix_userbundle_registrationformtype';
}
}
и, наконец, pix/userbundle/form/type/registrationformtype.php:
namespace Pix\UserBundle\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Pix\UserBundle\Form\DocumentType;
use Pix\UserBundle\Entity\AbilityRepository;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class RegistrationFormType extends AbstractType
{
public function __construct($class = "User")
{
parent::__construct($class);
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->remove('username');
$builder
->add('firstname', TexType::class, array(
'label' => 'Prénom',
))
->add('lastname', TexType::class, array(
'label' => 'Nom',
))
->add('phone', TexType::class, array(
'label' => 'Téléphone',
))
->add('street', 'hidden')
->add('number', 'hidden')
->add('npa', 'hidden')
->add('city', 'hidden')
->add('state', 'hidden')
->add('country', 'hidden')
->add('latitude', 'hidden')
->add('longitude', 'hidden')
->add('code', TexType::class, array(
'label' => 'Code de parrainage',
'required' => false
))
/*
->add('contact', 'choice', array(
'label' => 'Moyen de contact favorisé',
'choices' => array(
true => 'Par téléphone',
false => 'Par e-mail',
),
'expanded' => true,
'multiple' => false,
'required' => true
))
*/
->add('pro', 'choice', array(
'label' => false,
'choices' => array(
true => 'Oui',
false => 'Non',
),
'expanded' => false,
'multiple' => false,
'required' => true
))
->add('iban', TexType::class, array(
'label' => 'IBAN',
'required' => false
))
->add('distance', TexType::class, array(
'label' => "Rayon d'intervention",
'required' => false
))
->add('picture', new DocumentType(), array('required' => false))
->add('curriculum', new DocumentType(), array('required' => false))
->add('motivation', new DocumentType(), array('required' => false))
->add('document', new DocumentType(), array('required' => false))
->add('abilities', 'entity', array(
'label' => 'Domaines de compétence',
'attr' => array(
'class'=>'form-control multiselect'
),
'class' => 'PixUserBundle:Ability',
'property' => 'title',
'multiple' => true,
'expanded' => true,
'required' => false,
'query_builder' => function(AbilityRepository $er) {
return $er->getAbilities();
},
))
->add('condition', 'checkbox', array('label' => "J'ai lu et j'accepte les conditions générales."))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Pix\UserBundle\Entity\User',
'intention' => 'registration'
));
}
public function getBlockPrefix()
{
return 'pix_userbundle_registrationformtype';
}
public function getParent()
{
return RegistrationFormType::class;
}
}
Подробнее здесь: https://stackoverflow.com/questions/554 ... ady-in-use
Ошибка компиляции: не может объявить класс, потому что имя уже используется ⇐ Php
Кемеровские программисты php общаются здесь
1749004213
Anonymous
Я мигрирую на веб -сайте с Symfony 2.6 на 3.4, и у меня есть некоторые проблемы с регистрационными формами и Fosuserbundle. У меня появляется эта ошибка. Я проверил его код и увидел, что под его SRC \ Pix \ UserBundle \ Form \ RegistrationFormType.php, но есть еще одна папка «тип» с файлом с тем же именем: «RegistrationFormType.php» < /p>
Я пробовал изменить форму с новейшим стилем, взятым оттуда: оттуда: < /p>
Я пробовал изменить форму новейшим стилем: < /p>
https://github.com/symfony/symfony/blob/2.8/upgrade-2.8.md#form
app/config/config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: Pix\UserBundle\Entity\User
registration:
form:
type: Pix\UserBundle\Form\RegistrationFormType
validation_groups: [ pix_registration, Default ]
Файл службы в Pix/Userbundle/Resources/config/services.yml
services:
pix_userbundle_registrationformtype:
class: Pix\UserBundle\Form\Type\RegistrationFormType
arguments: ["%fos_user.model.user.class%"]
tags:
- { name: form.type }
pix/userbundle/form/registrationformtype.php:
namespace Pix\UserBundle\Form;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class RegistrationFormType extends AbstractType
{
public function __construct($class = "User")
{
parent::__construct($class);
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('username', 'text', array(
'label' => 'Pseudonyme',
))
->add('email', 'text', array(
'label' => 'Adresse mail',
))
->add('plainPassword', 'repeated', array(
'type' => 'password',
'first_options' => array('label' => 'Mot de passe'),
'second_options' => array('label' => 'Confirmation'),
'invalid_message' => 'Mot de passe incorrect',
))
->add('enabled', 'checkbox', array(
'label' => "Activé",
'required' => false
))
->add('firstname', 'text', array(
'label' => 'Prénom',
))
->add('lastname', 'text', array(
'label' => 'Nom',
))
->add('phone', 'text', array(
'label' => 'Téléphone',
))
->add('street', 'text', array(
'label' => "Adresse postale",
'required' => true
))
->add('number', 'text', array(
'label' => "Numéro d'adresse",
'required' => true
))
->add('npa', 'text', array(
'label' => "Code postal",
'required' => true
))
->add('city', 'text', array(
'label' => "Ville",
'required' => true
))
->add('state', 'text', array(
'label' => "Canton",
'required' => true
))
->add('country', 'text', array(
'label' => "Pays",
'required' => true
))
->add('latitude', 'text', array(
'label' => "Latitude",
'required' => true
))
->add('longitude', 'text', array(
'label' => "Longitude",
'required' => true
))
->add('code', 'text', array(
'label' => 'Code de parrainage',
'required' => false
))
->add('pro', 'choice', array(
'label' => "Professionel",
'choices' => array(
true => 'Oui',
false => 'Non',
),
'expanded' => false,
'multiple' => false,
'required' => true
))
->add('iban', 'text', array(
'label' => 'IBAN',
'required' => false
))
->add('distance', 'text', array(
'label' => "Rayon d'intervention",
'required' => false
))
->add('picture', new DocumentType(), array('required' => false))
->add('curriculum', new DocumentType(), array('required' => false))
->add('motivation', new DocumentType(), array('required' => false))
->add('document', new DocumentType(), array('required' => false))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Pix\UserBundle\Entity\User'
));
}
public function getParent()
{
return BaseRegistrationFormType::class;
}
public function getBlockPrefix()
{
return 'pix_userbundle_registrationformtype';
}
}
и, наконец, pix/userbundle/form/type/registrationformtype.php:
namespace Pix\UserBundle\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Pix\UserBundle\Form\DocumentType;
use Pix\UserBundle\Entity\AbilityRepository;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class RegistrationFormType extends AbstractType
{
public function __construct($class = "User")
{
parent::__construct($class);
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->remove('username');
$builder
->add('firstname', TexType::class, array(
'label' => 'Prénom',
))
->add('lastname', TexType::class, array(
'label' => 'Nom',
))
->add('phone', TexType::class, array(
'label' => 'Téléphone',
))
->add('street', 'hidden')
->add('number', 'hidden')
->add('npa', 'hidden')
->add('city', 'hidden')
->add('state', 'hidden')
->add('country', 'hidden')
->add('latitude', 'hidden')
->add('longitude', 'hidden')
->add('code', TexType::class, array(
'label' => 'Code de parrainage',
'required' => false
))
/*
->add('contact', 'choice', array(
'label' => 'Moyen de contact favorisé',
'choices' => array(
true => 'Par téléphone',
false => 'Par e-mail',
),
'expanded' => true,
'multiple' => false,
'required' => true
))
*/
->add('pro', 'choice', array(
'label' => false,
'choices' => array(
true => 'Oui',
false => 'Non',
),
'expanded' => false,
'multiple' => false,
'required' => true
))
->add('iban', TexType::class, array(
'label' => 'IBAN',
'required' => false
))
->add('distance', TexType::class, array(
'label' => "Rayon d'intervention",
'required' => false
))
->add('picture', new DocumentType(), array('required' => false))
->add('curriculum', new DocumentType(), array('required' => false))
->add('motivation', new DocumentType(), array('required' => false))
->add('document', new DocumentType(), array('required' => false))
->add('abilities', 'entity', array(
'label' => 'Domaines de compétence',
'attr' => array(
'class'=>'form-control multiselect'
),
'class' => 'PixUserBundle:Ability',
'property' => 'title',
'multiple' => true,
'expanded' => true,
'required' => false,
'query_builder' => function(AbilityRepository $er) {
return $er->getAbilities();
},
))
->add('condition', 'checkbox', array('label' => "J'ai lu et j'accepte les conditions générales."))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Pix\UserBundle\Entity\User',
'intention' => 'registration'
));
}
public function getBlockPrefix()
{
return 'pix_userbundle_registrationformtype';
}
public function getParent()
{
return RegistrationFormType::class;
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/55464088/compile-error-cannot-declare-class-because-the-name-is-already-in-use[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия