php zend框架表单显示组

php zend框架表单显示组,php,zend-framework,frameworks,Php,Zend Framework,Frameworks,Im使用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_Spee

Im使用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;'))
));
我得到这个错误:

没有为显示组指定有效的元素


问题出在哪里?

元素的定义有错误。此错误表示显示组中没有由您设置的元素:

        $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' ));

不我测试了这段代码,但不起作用。关键是,代码在我自己的计算机上运行时不会出错,但在服务器上会出错!实际上,在zend framework 1的最终子版本中,数组('profile')和数组($profile)是相同的!代码100%正确:)您确定服务器上的代码和进一步配置完全相同(没有缓存结果、忘记上载等),并且确定错误相同吗?只是想一想;服务器上的foreach中是否有任何值(因此选择列表中至少有一条记录)?