我使用zend表单和显示组,代码如下:
$profile=new Zend_Form_Element_Select('profile');
$profile->setLabel('name of profile');
foreach ($Current_User_Profile['profiles'][0] as $pro)
$profile->addMultiOption($pro,$pro);
$profile->setValue($Model_Port_Speed->Current_User_Profile($Current_User_Profile['my_user_id'], $Current_User_Profile['username']));
$Form_User_Settings->addDisplayGroup(array($profile), 'profile_change',array ('legend' => 'profile name here' ));
$profile_change = $Form_User_Settings->getDisplayGroup('profile_change');
$profile_change->setDecorators(array(
'FormElements',
'Fieldset',
array('HtmlTag',array('tag'=>'div','style'=>'width:100%;float:right;'))
));
我收到此错误:
没有为显示组
指定有效元素
问题出在哪里?
答案 0 :(得分:2)
元素定义中存在错误。此错误表示您的显示组中没有由您设置的元素:
$Form_User_Settings->addDisplayGroup(array($profile), 'profile_change',array ('legend' => 'profile name here' ));
应该是:
$Form_User_Settings->addDisplayGroup(array('profile'), 'profile_change',array ('legend' => 'profile name here' ));