Re: Form_Builder: how do you add a 'static' QuickForm element?

From: Date: Fri, 07 Jan 2005 18:01:38 +0000
Subject: Re: Form_Builder: how do you add a 'static' QuickForm element?
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16790@lists.php.net to get a copy of this message
On Fri, 07 Jan 2005 11:00:26 +0100, Arne Gellhaus <arne.gellhaus@gellhaus.de> wrote: > l Burnerheimerton wrote: > > > I can't get it to work in preDefElements because it's not one. > > > > Whatever the code format, I assume should work for header, hidden > > elements not in your database fields list, html, image, or anything > > that is not in the predefined list of fields DataObject generated. > > Additionally to your preDefElement you need a virtual field. The > concept of virtual fields is described here: > > http://opensource.21st.de/tiki-index.php?page=Beyond+Advanced#id323241 > > A hidden virtual field: > > function table() > { > $virtualfields = array(); > $virtualfields['test'] = DB_DATAOBJECT_STR; > return array_merge(parent::table(), $virtualfields); > } > > function preGenerateForm($fb) > { > $this->fb_preDefElements = array(); > > $hidden =& HTML_QuickForm::createElement('hidden', 'test'); > $this->fb_preDefElements['test'] = &$hidden; > $this->test = '123'; > } > > If you use $fb_fieldsToRender and/or $fb_preDefOrder don't forget to > put your hidden field in there too. > > Arne > Please don't. The virtual fields concept is a bit heavy for this. See my previous response to this thread. You can use postGenerateForm and insertElementBefore to put the filed where you want it. -- Justin Patrin

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