Symfony1 Symfony:embeddeRelationship()用于嵌套多级关系的控制选项

Symfony1 Symfony:embeddeRelationship()用于嵌套多级关系的控制选项,symfony1,embed,relationship,nested,Symfony1,Embed,Relationship,Nested,我试图为嵌套的EmbedderRelation实例设置一些条件语句,但找不到一种方法来获得第二个embedRelation的任何类型的选项 我有一个度量->页面->问题表关系,我希望能够选择是否显示问题表。例如,假设我有两个成功页面,page1Success.php和page2Success.php。在第1页上,我想显示Measure->Page->Question,在第2页上,我想显示Measure->Page,但我需要一种方法将一个选项传递给PageForm.class.php文件以做出这种

我试图为嵌套的EmbedderRelation实例设置一些条件语句,但找不到一种方法来获得第二个embedRelation的任何类型的选项

我有一个度量->页面->问题表关系,我希望能够选择是否显示问题表。例如,假设我有两个成功页面,page1Success.php和page2Success.php。在第1页上,我想显示Measure->Page->Question,在第2页上,我想显示Measure->Page,但我需要一种方法将一个选项传递给PageForm.class.php文件以做出这种决定。我的actions.class.php文件如下所示:


// actions.class.php
$this->form = new measureForm($measure, array('option'=>$option));
将一个选项传递给页面,但将该选项传递给页面并引起质疑是行不通的

我的measureForm.class.php文件中有一个依赖于以下选项的嵌入关系:


// 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');
}
我似乎找不到办法来做这件事。有什么想法吗

有没有一种更好的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

我决定改用嵌入表单。它最后变成了一些规则查询::创建->选择。。。getTable命令,后跟一些foreach循环和embeddeform语句。我们的关系到此为止

你有没有可能在你的问题中加入一个示例模式,因为我不太清楚你想达到什么目的。当然,没问题。我还更新了很多其他信息,以便更加清楚。