Re: several problems with DO and Formbuilder

From: Date: Tue, 02 Nov 2004 18:17:19 +0000
Subject: Re: several problems with DO and Formbuilder
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15304@lists.php.net to get a copy of this message
On Tue, 2 Nov 2004 02:05:38 +0100, Alexander Petri <alex.petri@gmx.de> wrote: > okay as you all can see from my last post with Dataobjects Formbuilder > i wanted to get a very special form from my table.... > > now i tried this: > > // Formularaufbau > function preGenerateForm(&$fb) { > $this->fb_preDefElements['password'] = > HTML_QuickForm::createElement('password', 'password', > 'Passwort',''); > $this->fb_preDefElements['h2'] = > HTML_QuickForm::createElement('header', 'h2', 'persönliche > Daten','asdasd'); > $this->fb_preDefElements['h3'] = > HTML_QuickForm::createElement('header', > 'h3', 'Fragebogen','asdasd....'); > $this->fb_preDefElements['pwd_2'] = > HTML_QuickForm::createElement('password', 'pwd_2', 'Passwort > wiederholen',''); > $this->fb_preDefElements['fr_1'] = > HTML_QuickForm::createElement('select', > 'fr_1', 'Möchten Sie einen Newsletter bestellen?',array(1=>'Ja, > ich möchte > einen Newsletter per Email erhalten', 2=>'Ja, ich möchte einen Newsletter > per Post erhalten', 3=>'Nein, ich möchte nicht informiert werden')); > } > function table() { > return array_merge(parent::table(), array( 'h2' => > DB_DATAOBJECT_STR, > 'h3' => DB_DATAOBJECT_STR, > 'fr_1' => DB_DATAOBJECT_STR, > 'pwd_2' => DB_DATAOBJECT_STR > )); > } > var > > $fb_fieldsToRender=array('anrede','firma','vorname','nachname','strasse','pl > z','ort','land_iso3166','gebdat', > > > 'email','telefon','telefax','mobil','personalnummer','h2','h3','pwd_2','fr_1 > ','password'); > > the header elements did not show up (only the text inside....but there is a > small thin line so that the element should be there)... why??? > Well, you're making the headers part of the table as strings...this isn't a very good solution IMHO. Remove them from the preDefElements array and from the overloaded table() and put them in the form in postGenerateForm with QF's new insertElementBefore() function. function postGenerateForm(&$form) { $h2 =& HTML_QuickForm::createElement('header', 'h2', 'persönliche Daten','asdasd'); $form->insertElementBefore($h2, 'pwd_2'); } See: http://pear.php.net/package/HTML_QuickForm/docs/3.2.4pl1/apidoc/HTML_QuickForm-3.2.4pl1/HTML_QuickForm.html#methodinsertElementBefore > nextone: > > function postGenerateForm(&$form) { > > $form->addRule('plz', 'Bitte geben Sie einen Postleitzahl > ein','required'); > $form->addRule('plz', 'Postleitzahl zu kurz','minlength', > 5); > $form->addRule('plz', 'Postleitzahl zu lang','maxlength', > 5); > } > > every required rule will be overwritten by the objects own errormessage.... > how can i fix that? I'm not quite sure what you're saying here. FormBuilder adds required rules for any "NOT NULL" columns in your database. If you don't want it to do this, try removing the NOT NULL type from the column. If you *must* have it this way, we may be able to add an option to stop it form adding these rules... > > and the last: > i have a birthDATEfield > how can i set the timeborders i.e. 1950-1990 The best way to do this right now is to use a preDefElement and pass the options into the createElement call. > > thanks for help... > Sorry for the lateness of the reply. Hope it helps. -- paperCrane --Justin Patrin--

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