gpt4 book ai didi

php - 在 Symfony 1.4 中订购嵌入式表单

转载 作者:行者123 更新时间:2023-11-30 01:19:14 24 4
gpt4 key购买 nike

我正在尝试按其中一个值在 SF1.4 后端模块中订购嵌入表单。

$this->embedRelation('MyInnerForm 作为innerForm');

给我一​​个表格,显示 MyInnerForm 中所有条目的编辑表单。我希望以正确的方式订购它。找不到修改查询以添加 orderBy-Option 或(更好)使用 PHP 对结果数组进行排序的方法。感谢您的建议。

最佳答案

看看embedRelation的代码:它只是获取您的关联,对其运行foreach并调用embedForm

  $subForm = new sfForm();
foreach ($this->getObject()->$relationName as $index => $childObject)
{
$form = $r->newInstanceArgs(array_merge(array($childObject), $formArgs));

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

$this->embedForm($fieldName, $subForm, $decorator);

看到$this->getObject()->$relationName部分了吗?无法订购嵌入表单,但您可以自行嵌入它们。

<?php
foreach ($this->getObject()->getMyInnerFormOrderedByStuff() as $index => $childObject)
{
$form = new InnerFormForm($childObject); // todo!!

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

$this->embedForm($fieldName, $subForm, $decorator);

您必须实现getMyInnerFormOrderedByStuff(),仅此而已。

关于php - 在 Symfony 1.4 中订购嵌入式表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18738466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com