1

我的“Default_Form_Registration”类中有以下代码(在 _init 方法中):

$fullname = $this->addDisplayGroup(
                       array('firstname', 'lastname'),
                       'fullname');
$fullname->setLegend('Full Name');

我的表单正在正确显示(字段集中的元素),但是没有显示图例。我根本没有改变装饰器,使用默认装饰器。

我究竟做错了什么?

4

1 回答 1

3

您可以通过addDisplayGroup第三个参数将选项传递给:

 $fullname = $this->addDisplayGroup(
                   array('firstname', 'lastname'),
                   'fullname', array('legend' => 'Full Name'));

另外,请注意,addDisplayGroup返回Zend_Form而不是显示组。

如果要使用该setLegend方法,则需要这样做:

 $this->getDisplayGroup('fullname')->setLegend('Full Name');
于 2011-07-17T17:29:11.060 回答