2016-06-02 10 views
0

私はたくさんの他のオプションを探そうとしていますが、私が見てきたスタックオーバーフローのような疑問がたくさんありますが、それらはすべてSymfonyやFOSUserBundleの古いバージョンを扱っています... FOSUserBundleのドキュメントでは、プロファイルページにカスタムフィールドを追加する方法、つまり登録ページのみを正確にカバーする方法については説明していません。FOSUserBundle ProfileFormTypeを上書きする方法は? - Symfony 3.1

Userクラスに追加したカスタムフィールドをユーザーのプロフィールページに表示するにはどうすればよいですか?私は他のすべてのスタックオーバーフローの試みを試みました。ここで

は私のservices.ymlです:

services: app.profile.form.type: class: AppBundle\Form\ProfileFormType tags: - { name: form.type, alias: app_user_profile }

は、ここに私のconfig.ymlです:

fos_user: profile: form: type: AppBundle\Form\ProfileFormType

そして、私のプロフィールクラスの多くのただ一回の反復: <?php namespace AppBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; class ProfileFormType extends AbstractType { public function buildUserForm(FormBuilderInterface $builder, array $options) { $builder->add('pokemon'); }

public function getParent() 
{ 
    return 'FOS\UserBundle\Form\Type\ProfileFormType'; 
} 

public function getBlockPrefix() 
{ 
    return 'app_user_profile'; 
} 

// For Symfony 2.x 
public function getName() 
{ 
    return $this->getBlockPrefix(); 
} 

} `

答えて

0

たぶん、あなたは親フォームのクラスを拡張する必要がありますか?

ProfileFormTypeは、パラメータクラス(ユーザエンティティ)は、プロフィールクラスでthroughtコンストラクタを

+0

作成されていることを確認してください:( –

0

を通過あり\ FOS \ UserBundle \フォーム\タイプ\ ProfileFormType { .... }

を拡張名前空間は、次のとおりです。名前空間AppBundle \フォーム\タイプ それはあなたがあなたのサービスに入れなければならないことを意味します

services: 
 
    app.profile.form.type: 
 
     class: AppBundle\Form\Type\ProfileFormType 
 
     tags: 
 
      - { name: form.type, alias: app_user_profile }

そして、あなたは、私はそれが機能しなかった、ということしようとしたフォルダの種類

関連する問題