私はDoctrineとFOSBundle 2.0を使ってSymfony3のアプリケーションを開発しています。登録フォームにフィールドを追加しようとすると「app_user_registration」タイプを読み込めませんでした
登録バーに2つのフィールドを追加しようとしています。ファーストネームとファーストネームです。
I have found this tutorial on how do do precisely what I'm hoping、残念ながら最初の数ステップ(前処理)にした後、私はこのエラーを取得しています実現:
Could not load type "app_user_registration"
私が使用しているコードはexacly唯一の違いは、webisteからをコピーしています私のクラスは、この
<?php
// src/AppBundle/Entity/User.php
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/** @ORM\Column(type="integer") */
protected $carma;
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="Please enter your first name.", groups={"Registration", "Profile"})
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
*)
*/
protected $firstName;
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="Please enter your first name.", groups={"Registration", "Profile"})
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
*)
*/
protected $lastName;
同じ効果のように見えるということですが発生...「名前」
という名前の変数が存在するとき私は最後の数時間を費やしています。
すべてが他の質問への答えとしての私の出力コードを示した2.0マスターバージョンのチュートリアルを使用する: 私が試したものがあります。
誰かが貧しい人々を助けることができますか?ここでさらにとして
は、私の他のファイルは、以下のとおりです。
//config.yml
/*...*/
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
registration:
form:
type: AppBundle\Form\RegistrationType
//services.yml
services:
app.form.registration:
class: AppBundle\Form\RegistrationType
tags:
- { name: form.type, alias: app_user_registration }
//RegistraionType.php
<?php
// src/AppBundle/Form/RegistrationType.php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('firstName');
}
public function getParent()
{
return 'fos_user_registration';
}
public function getName()
{
return $this->getBlockPrefix();
}
public function getBlockPrefix()
{
return 'app_user_registration';
}
}
このエラーは、お使いのUserエンティティではないが、そのアプリであなたが設定しているエイリアスを使用しようとしているから来ます/ config/services.ymlをあなたのユーザー登録フォームを参照してください。 – pogeybait
また、エラーが発生している場所であるため、フォームタイプの処理も行いましたか。他の例を探すときは注意してください。投稿した2番目のリンクは、古いバージョンのFOSUserBundle用です。確かに、あなたが見つけるほとんどの例は時代遅れです。 – Cerad