首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >致命错误:在非对象上调用成员函数load() (P4A应用程序框架)

致命错误:在非对象上调用成员函数load() (P4A应用程序框架)
EN

Stack Overflow用户
提问于 2012-10-22 22:13:40
回答 2查看 2.1K关注 0票数 2

我正在尝试使用P4A应用程序框架制作小部件,我有一个反射声音的代码,直到最后一个掩模,这应该使一个小部件产生给用户移动到另一个应该执行不同功能的掩模的能力,错误起源于代码所在的第28行;

代码语言:javascript
复制
->load($this->locations); 

我相信它扩展了类,但我不确定,任何帮助…代码的其余部分如下

代码语言:javascript
复制
class main_dashboard_mask extends P4A_Base_Mask
{

public $locations = array(
        array('value'=>'area1','description'=>'area one'),
        array('value'=>'area2','description'=>'area two'),
        array('value'=>'area3','description'=>'area three'),            
        );
public function __construct()
{
    parent::__construct();
    $p4a = p4a::singleton();
    $this->setTitle("Dashboard");

    $this->build('p4a_field','MeetingRooms');
    $this->MeetingRooms->setLabel("This is the meeting room label");
    $this->build('p4a_button', 'continue')
    ->setLabel('Continue?')
    ->implement("onclick", $this, "change");
   $this->build('p4a_field','booking')
    ->setlabel('Viewing?')
    ->setType('checkbox')
    ->setValue(true);
    $this->booking->label->setTooltip('If you are booking a meeting room, check this box');

    $this->build("P4A_Array_Source", "location")
    ->getPk("value")
    ->load($this->locations);
    $this->build('p4a_field','location')
    ->setLabel('location')
    ->setValue('area1')
    ->setType('select')
    ->setSource($this->location)
    ->setWidth(60);
    $this->weight->label->setWidth(60);
    $this->MeetingRooms();
}

private function MeetingRooms()
{
    $this->build('P4A_fieldset', 'widgetframe')
    ->anchor($this->location)
    ->anchorLeft($this->booking)
    ->anchorLeft($this->continue)
    ->setLabel('Meeting Room Bookings');
}

}

任何帮助都将不胜感激=]。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-26 23:26:02

好的,试试这个,它可能对你更好。

代码如下:

代码语言:javascript
复制
public function __construct()
{
    parent::__construct();
    $this->setTitle("Dashboard");

    $this->build('p4a_field','MeetingRooms');
    $this->MeetingRooms->setLabel("This is the meeting room label");
    $this->build('p4a_button', 'continue')
    ->setLabel('Continue?')
    ->implement("onclick", $this, "change");

   $this->build('p4a_field','booking')
    ->setlabel('Booking?')
    ->setType('checkbox')
    ->setValue(false);

    $this->booking->label->setTooltip('If you are booking a meeting room, check this box');



    $this->build("p4a_db_source", "login")
    ->setTable("meetingrooms")
    ->load()
    ->firstRow();

    $this->build('p4a_field','location')
    ->setSource($this->login)
    ->setLabel('location')
    ->setType('select')
    ->setSourceValueField("position")
    ->setSourceDescriptionField("MeetingRoom")
    ->setWidth(120);


    $this->build("p4a_fieldset","Book")
    ->anchor($this->location)
    ->anchor($this->booking)
    ->anchor($this->continue)
    ->setLabel('Meeting room bookings');

    $this->display("main",$this->Book);


}


}

祝你好运:)谢谢你接受我的才华xx

票数 1
EN

Stack Overflow用户

发布于 2012-10-22 23:51:08

通过查看类引用和代码,P4A_Data_Source::getPk()返回一个字符串,而不是一个对象,这就是为什么会出现错误。默认情况下,PK的值看起来是NULL,这可能会猜想你是在返回。此外,getPk方法似乎不接受任何参数。

您可以通过以不同的顺序链接来修复此问题:

代码语言:javascript
复制
$this->build("P4A_Array_Source", "location")
     ->load($this->locations)
     ->getPk();

这看起来是正确的,因为调用load()设置了PK。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13013290

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档