Re: Db_DataObject and Formbuilder virtual fields

From: Date: Fri, 22 Jul 2005 16:13:13 +0000
Subject: Re: Db_DataObject and Formbuilder virtual fields
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20100@lists.php.net to get a copy of this message
Saqib wrote:
whats wrong with this?!?!??!? if you make a virtual field in the DataObject and try in the callback function preGenerateForm to make the preDefElemet it did not apper when form->display() is called why?!? her is the code.
    function table()
    {
        return array_merge(parent::table(), array('virtualField' => DB_DATAOBJECT_INT));
    }
    //stop the virtual field from being in the INSERT
    function insert()
    {
        if (isset($this->virtualField)) {
            unset($this->virtualField);
        }
        parent::insert();
    }
    //stop the virtual field from being in the UPDATE
    function update($do = false)
    {
        if (isset($this->virtualField)) {
            unset($this->virtualField);
        }
        if (is_object($do) && isset($do->virtualField)) {
            unset($do->virtualField);
        }
        parent::update($do);
    }
    function preGenerateForm( &$fb )
    {
        $nr[0]="text1";
        $nr[1]="text2";
        $this->fb_preDefElements['virtualField'] = HTML_QuickForm::createElement('select', 'virtualField','News Kategorie',$nr);
    }
i found the problem ;-) the "problem" was that i used elementNamePrefix


« previous php.pear.general (#20100) next »