Php Symfony 1-如何从foreach创建链接
我对Symfony 1真的很陌生。我知道它很旧,对这个版本的支持已经结束。但我实习的公司有一个项目仍然运行在symfony 1.4上 我有一个foreach循环Php Symfony 1-如何从foreach创建链接,php,symfony1,symfony-1.4,Php,Symfony1,Symfony 1.4,我对Symfony 1真的很陌生。我知道它很旧,对这个版本的支持已经结束。但我实习的公司有一个项目仍然运行在symfony 1.4上 我有一个foreach循环 <?php foreach ($configuration->getFormFields($form, 'show') as $fieldset => $fields): ?> <?php //include_partial('service/form_fieldset', array('s
<?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; ?>
但我的知识仍然缺乏很多来解决这个问题。我非常感谢您的帮助?如果您有到详细信息页面的路径,我会使用url\u和给定的$parentId尝试以下操作:
<?php if ($field->getConfig('label') == "parent_service_description"): ?>
<td>
<a href="<?php echo url_for('@show_details?id=' . $parentId) ?>">
<?php echo $form->getObject()->get($name) ? $form->getObject()->get($name) : "-" ?>
</a>
</td>
您应该使用
echo link_to ($name, "action/module?id=". $sf_params->get("id") . "¶ms2=2") )
背后的原因是它的可读性和简单性。谢谢,我知道我的方向是正确的。(我希望是D)
echo link_to ($name, "action/module?id=". $sf_params->get("id") . "¶ms2=2") )