ネストされたembedRelation()インスタンスにいくつかの条件ステートメントを設定しようとしていますが、2番目のembedRelationまで任意の種類のオプションを取得する方法が見つかりません.
「メジャー -> ページ -> 質問」テーブルの関係があり、質問テーブルを表示するかどうかを選択できるようにしたいと考えています。たとえば、page1Success.php と page2Success.php という 2 つの「成功」ページがあるとします。page1に「Measure->Page->Question」、page2に「Measure->Page」と表示したいのですが、PageFormに「option」を渡す方法が必要です。 .class.php ファイルを使用して、そのような決定を下します。私の actions.class.php ファイルには次のようなものがあります。
// actions.class.php
$this->form = new measureForm($measure, array('option'=>$option));
オプションを「ページ」に渡しますが、そのオプションを「ページ」から「質問」に渡すことはできません。
私のmeasureForm.class.phpファイルには、「オプション」に依存するembedRelationがあります。
// measureForm.class.php
if ($this->getOption('option') == "page_1") {
$this->embedRelation('Page');
}
これは私のpageForm.class.phpファイルでやりたいことです:
// pageForm.class.php
if ($this->getOption('option') == "page_1") { // Or != "page_2", or whatever
$this->embedRelation('Question');
}
これを行う方法が見つからないようです。何か案は?
おそらくembedRelationなしで、このタイプの操作を行うSymfonyの好ましい方法はありますか?
ありがとう - トレバー
要求に応じて、これが私の schema.yml です。
# schema.yml
Measure:
connection: doctrine
tableName: measure
columns:
_kp_mid:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
description:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
frequency:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Page:
local: _kp_mid
foreign: _kf_mid
type: many
Page:
connection: doctrine
tableName: page
columns:
_kp_pid:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
_kf_mid:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
next:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
number:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
previous:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Measure:
local: _kf_mid
foreign: _kp_mid
type: one
Question:
local: _kp_pid
foreign: _kf_pid
type: many
Question:
connection: doctrine
tableName: question
columns:
_kp_qid:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
_kf_pid:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
text:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
type:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Page:
local: _kf_pid
foreign: _kp_pid
type: one