0

是否可以在 embedRelation 上设置 where 子句?

$this->embedRelation('treatedStones');

我需要得到其中stone_free = 0 的处理过的石头

4

1 回答 1

1

我认为你不能这样做embedRelation,但你可以像在sfFormDoctrine.

$subForm = new sfForm();

// create a custom query e.g. in `TreatedStoneTable::queryFree($relatedId)` and
// a method to the class of `$this->getObject()` to retrieve free stones 
// e.g. `Class::getFreeTreatedStones()` to call the query
foreach ($this->getObject()->getFreeTreatedStones() as $index => $childObject)
{
  $form = new TreatedStoneForm($childObject);

  $subForm->embedForm($index, $form);
  $subForm->getWidgetSchema()->setLabel($index, (string) $childObject);
}

$this->embedForm('treated_stones', $subForm);

您可以在文档中找到有关表单如何工作的更多详细信息。

于 2012-08-10T14:04:40.100 回答