【发布时间】:2016-03-07 09:12:54
【问题描述】:
我对 Symfony 1 真的很陌生。我知道它已经过时了,并且对这个版本的支持已经结束。但是我实习的公司的一个项目仍然在 symfony 1.4 上运行。
我有一个 foreach 循环;
<?php foreach ($configuration->getFormFields($form, 'show') as $fieldset => $fields): ?>
<?php //include_partial('service/form_fieldset', array('service' => $service, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?>
<table id="sf_fieldset_<?php echo preg_replace('/[^a-z0-9_]/', '_', strtolower($fieldset)) ?>" cellspacing="0" cellpadding="0" class="sf_admin_st">
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<?php
$i = 0;
foreach ($fields as $name => $field):
?>
<?php $i++;
$class = ($i % 2 == 0) ? 'even' : 'odd';
?>
<?php $attributes = $field->getConfig('attributes', array()); ?>
<?php if ($field->isPartial()): ?>
<?php include_partial('service/' . $name, array('service' => $service, 'form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php elseif ($field->isComponent()): ?>
<?php include_component('service', $name, array('service' => $service, 'form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php else: ?>
<tr class="<?php echo $class ?>">
<td><?php echo $field->getConfig('label') ? $field->getConfig('label') : $field->getName() ?>:</td>
<td><?php echo $form->getObject()->get($name) ? $form->getObject()->get($name) : "-" ?></td>
<?php endif; ?>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</table>
<?php endforeach; ?>
上述代码输出表如下;
我的问题是,如何使表格中的字段成为指向该特定描述的链接。我希望表中的 Parent Service 值成为指向该特定值的链接。
我想过一个如果,像这样;
<?php if ($field->getConfig('label') == "parent_service_description"): ?>
<td><a href="#"><?php echo $form->getObject()->get($name) ? $form->getObject()->get($name) : "-" ?></a></td>
<?php else: ?>
<td><?php echo $form->getObject()->get($name) ? $form->getObject()->get($name) : "-" ?></td>
<?php endif; ?>
但是我的知识仍然缺乏解决这个问题。非常感谢您的帮助,好吗?
【问题讨论】:
标签: php symfony1 symfony-1.4