【问题标题】:php zend framework form display groupphp zend框架表单展示组
【发布时间】:2013-08-01 13:29:19
【问题描述】:

我使用 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;'))
));

我得到这个错误:

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

问题出在哪里?

【问题讨论】:

    标签: php zend-framework frameworks


    【解决方案1】:

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

            $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的最终子版本中,array('profile')和array($profile)是一样的!跨度>
    • 代码 100% 正确 :) 你确定服务器上的代码和进一步的配置完全一样(没有缓存结果,忘记上传等),你确定错误是一样的吗?
    • 只是一个想法;服务器上的 foreach 中是否有任何值(因此选择列表中至少有一条记录)?
    猜你喜欢
    • 2011-06-23
    • 1970-01-01
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-20
    • 2010-11-16
    • 1970-01-01
    相关资源
    最近更新 更多