Re: HTML_QuickForm usage advise wanted

From: Date: Mon, 07 Jun 2004 20:52:10 +0000
Subject: Re: HTML_QuickForm usage advise wanted
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12982@lists.php.net to get a copy of this message
What I often do is write the common part of "creating" and "editing" forms in an include file. Like this: [include file] // The main block of code for the form of Page1 $GLOBALS['block_page1'] = ' // first name $this->addElement( "text", "first_name", "First name", "size=20" ) ; // etc. ; [create file] class Page1 extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; // Include the form's page 1 main chunk eval( $GLOBALS['block_page1'] ) ; // ... // add other elements specific to the "create" situation } // instantiating the controller... // set default elements specific to the "create" situation HTH Ignatius _________________________ "Ian P. Christian" <pookey@pookey.co.uk> wrote in message news:200406051847.52205.pookey@pookey.co.uk... -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've been using HTML_QuickForm for a while, and I often find myself wanting to do the same thing with it, and have yet to come up with a solution that I'm 100% satisfied with, so I thought I would ask here to see if anyone has a clean solution. I use HTML_QuickForm with DB_DataObject, and I often want to use the same form I use for creating an entry, to be used for viewing and editing. All of the forms I construct as done so in the constructor of a class I extend from HTML_QuickForm. The problem is, when viewing a record, the main form heading needs changing to 'Viewing ....', when editing, it's 'Editing....' and when creating, it's 'Creating....'. Other changes involve setting up the submit buttons, for example, when the form is in 'view' mode, a 'delete' and 'edit' button might want to be added to the form. As the form is generated in the constructor, the only way of achiving this would be to add a setMode() function to my forms, where you can change the mode of a form, but then the class would need to go back and remove/edit elements that has already been added to the form. The other alternative was to pass the mode, and the default data in the constructor to the form. Does anyone have any suggestions, or a better way of doing this? Kind Regards, - -- Ian P. Christian - pookey@pookey.co.uk - http://www.pookey.co.uk/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFAwgdHEe6ncNCcEO0RAszzAJ9ECl6ElHkRK7fMiYIFjMOS6ld77QCgyIEg Oly2IsYtDZiZSUUXtb0ZB1k= =Zl5v -----END PGP SIGNATURE-----

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