1

我只想像这样创建一个标签/值行:

<label>
    <span>My Label:</span><span>My value from my object</span>
</label>

那么我应该在type属性中添加什么?

$this->add(array (
    'name' => 'myFieldName',
    'attributes' => array(
        'type' => '???????',
    ),
    'options' => array (
        'label' => 'My Label:',
    ),
));
4

1 回答 1

3
$this->add(array (
    'name' => 'myFieldName',
    'type' => 'hidden',
    'options' => array (
        'label' => 'My Label:',
    ),
));

并且在视图中

<?php $element = $form->get('myFieldName') ?>
<label>
    <span><?php echo $element->getLabel() ?></span>
    <span><?php echo $this->escapeHtml($element->getValue()) ?></span>
</label>
于 2013-07-24T12:53:09.960 回答