Re: where is the data on my custom Form??? DO_QF_Builder

From: Date: Fri, 29 Oct 2004 16:22:52 +0000
Subject: Re: where is the data on my custom Form??? DO_QF_Builder
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15227@lists.php.net to get a copy of this message
On Fri, 29 Oct 2004 17:05:14 +0200, Alexander Petri <alex.petri@gmx.de> wrote: > i have done a custom Form > > class CustomSmarty extends HTML_QuickForm { > function CustomSmarty($formName='CustomerForm',$method='post', > $action='', > $target='_self', $attributes=null) { > parent::HTML_QuickForm($formName, $method, $action, $target, > $attributes,true); > // Part 1 > $this->addElement('header', 'h_1', 'Bitte vergeben Sie Sich ein > neues > Passwort!'); > $this->addElement('password', 'password', 'neues Passwort', > 'size=20'); > $this->addElement('password', 'password2', 'Passwort > wiederholen', > 'size=20'); > $this->addRule('password','Passwort zu kurz!','required'); > $this->addRule('password','Passwort zu > kurz!','minlength',6); > $this->addRule('password','Passwort zu > lang!','maxlength',30); > $this->addRule(array('password', 'password2'), 'Die Passwörter > sind nicht > gleich!', 'compare', null, 'server'); > > // Part 2 > $this->addElement('header','h_2','persönliche Daten > ändern'); > $this->addElement('text', 'anrede', 'Anrede'); > $this->addElement('text', 'firma', 'Firma'); > $this->addElement('text', 'vorname', 'Vorname'); > $this->addElement('text', 'nachname', 'Nachname'); > $this->addElement('date','gebdat','Birthdate'); > $this->addElement('text', 'strasse', 'Adresse'); > $this->addElement('text', 'plz', 'Postleitzahl'); > $this->addElement('text', 'ort', 'Ort'); > $this->addElement('select', 'land_iso3166', > > 'Land',array("DE"=>"DE","FR"=>"FR","UK"=>"UK")); > $this->addElement('text', 'email', 'Email'); > $this->addElement('text', 'telefon', 'Telefon'); > $this->addElement('text', 'telefax', 'Telefax'); > $this->addElement('text', 'mobil', 'Telefax'); > $this->addElement('text', 'personalnummer', 'Telefax'); > > // Part 3 > $this->addElement('header','h_3','Fragebogen'); > $this->addElement('radio', 'r_grp', 'Newsletter anmelden', > 'Test'); > > $this->addElement('submit', 'submit', 'Register'); > $this->applyFilter('__ALL__', 'trim'); > //$this->addGroupRule('pass', 'Passwort wird benötigt', > 'required'); > } > } > > //////////////////////////////////////////////////////////////// > require_once('DB/DataObject/FormBuilder/QuickForm.php'); > class userForm extends DB_DataObject_FormBuilder_QuickForm { > function &getForm($action=false, > $target='_self',$formName='CustomerForm', > $method='post'){ > if (!$action) { > $action = $_SERVER['REQUEST_URI']; > } > $form =& new CustomSmarty($formName, $method, $action,$target); > return $form; > } > } > ////////////////////////////////////////////////////////////////////// > in my applicationcode > i run this > > $user = DB_DataObject::factory('app_user'); > $user->username = $_SESSION['_authsession']['username']; > $num = $user->find(); > $user->fetch(); > $builder =& new userForm($user); > $form =& $builder->getForm(); > if($form->validate()){ > $form->process(array(&$builder,'processForm'),false); > }else{ > require_once 'HTML/QuickForm/Renderer/Array.php'; > > $renderer =& new HTML_QuickForm_Renderer_Array(true, true); > $form->accept($renderer); > $smarty->assign('form', $renderer->toArray()); > } > > but ther is no prefilled data.... where is it??? > i had to do a custom form because my client wanted a separation > could someone help me? > If you use getForm() FormBuilder assumes you're giving it the *entire* form and does no form generation. You probably want something more like this: $form =& new CustomSmarty(); $builder->useForm($form); $form =& $builder->getForm(); And remove the getForm method from your DO. Or you could rename it to...say, getCustomForm and do: $form =& $do->getCustomForm(); $builder->useForm($form); $form =& $builder->getForm(); -- paperCrane --Justin Patrin--

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