ラジオボタンですべてのカテゴリ(私のテーブルカテゴリから)を表示しようとしています。 3つのカテゴリがありますが、1つのラジオボタンだけが表示され、DoctrineクエリはOKです。Symfony2:ラジオボタンとしてフォームエンティティのフィールドタイプを表示
私にformTypeコード:
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('categories', 'entity', array(
'class' => 'MyBundle:Category',
'expanded' => true,
'property' => 'title',
'property_path' => false,
));
}
マイ小枝コード:
{{ form_widget(form) }}
結果は3つのラジオボタンを返す必要がありますが、私は1つのラジオボタンのみ(私のテーブル内の最初の)を参照してください。
Symfonyプロファイラ(デバッグバー)に表示されるDoctrineクエリは完全に実行され、3行を返します。
たぶん、問題はそれ以外の場合は、私は例外を持っていた、私は追加する必要がありました「property_path」から来ている:
Neither property "categories" nor method "getCategories()" nor method "isCategories()" exists in class ...
任意のヘルプしてください? "property_path" を削除するときにここで
は、この要求に対応する私のdev.logです:
オーレル
EDIT :-)
感謝
[2012-04-26 07:27:01] doctrine.DEBUG: SELECT t0.id AS id1, t0.last_update AS last_update2, t0.title AS title4 FROM category t0 ([]) [] []
[2012-04-26 07:27:01] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException". [] []
[2012-04-26 07:27:01] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". [] []
[2012-04-26 07:27:01] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". [] []
[2012-04-26 07:27:01] request.CRITICAL: Symfony\Component\Form\Exception\InvalidPropertyException: Neither property "categories" nor method "getCategories()" nor method "isCategories()" exists in class "Acme\MyBundle\Entity\Category" (uncaught exception) at /www/vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php line 316 [] []
I実際に私のカテゴリテーブルの各行を表示することを拒否した理由を理解できません...
これ以上ヘルプがありますか? 3つのラジオボタンをどのように表示できますか?なぜ彼らはすべて回収されていないのですか? – Aurel