Re: Re: Db_DataObject and Formbuilder virtual fields
| From: | Justin Patrin | Date: | Fri, 22 Jul 2005 17:08:42 +0000 |
| Subject: | Re: Re: Db_DataObject and Formbuilder virtual fields | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20106@lists.php.net to get a copy of this message | ||
On 7/22/05, Saqib <saja20@gmx.net> wrote:
> 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);
Indeed, the "problem" is elementNamePrefix. For this reason you should
do preDefElements (or anything which needs an element name for the
form) like this:
$this->fb_preDefElements['virtualField'] =
HTML_QuickForm::createElement('select',
$fb->getFieldName('virtualField'),'NewsKategorie',$nr);
> > }
> i found the problem ;-) the "problem" was that i used elementNamePrefix
>
--
Justin Patrin