gpt4 book ai didi

php - Zend Framework 如何使用 partialLoop 列出表单元素

转载 作者:可可西里 更新时间:2023-10-31 22:49:50 24 4
gpt4 key购买 nike

我是 Zend Framework 的新手,不确定这是否可行。

我想使用 partialloop 来创建包含表单字段的表格。

我在 View 中使用这段代码:

<!-- code in views/scripts/request/edit.phtml -->

<table cellpadding='0' cellspacing='0'>
<tr>
<th>Cliente</th>
<th>Descripcion</th>
</tr>
<?php echo $this->partialLoop('partials/_solicitud-row.phtml', $this->form); ?>
</table>

在部分我试过这个:

<!-- code in views/scripts/partials/_solicitud-row.phtml -->
<tr>
<td><?php echo $this->key . "=" . $this->value; ?></td>

</tr>

还有这个

 <!-- code in views/scripts/partials/_solicitud-row.phtml -->
<tr>
<td><?php echo $this->Descripcion; ?></td>
<td><?php echo $this->cliente; ?></td>
<td><?php echo $this->FechaHoraCreada; ?></td>
<td><?php echo $this->Monto; ?></td>

</tr>

使用它我得到了表格的标题 ( <tr><th>Cliente</th><th>Descripcion</th></tr> ) 但仅此而已。我知道部分已处理,因为使用第一个部分列出了等号“=”。

我在做什么有意义吗?有没有办法访问表单元素?我尝试了其他选项,例如 $this->getElement..,但没有用

谢谢!

最佳答案

partialLoop 函数可以处理您的表单元素,但您需要稍微备份一下:

  <!-- code in views/scripts/request/edit.phtml -->
<?php
$model = array();
foreach ( $this->form as $element ) {
// include the $element itself, instead of the
// $element public properties (which are few)
$model[] = array('element' => $element);
}
?>
<?php echo $this->partialLoop('partials/_solicitud-row.phtml', $model); ?>

.

  <!-- code in views/scripts/partials/_solicitud-row.phtml -->
<?php echo $this->element->getName(). "=" . $this->element->getValue(); ?>

关于php - Zend Framework 如何使用 partialLoop 列出表单元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1923869/

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