Re: QF, setting textarea value(?)

From: Date: Mon, 06 Oct 2003 14:47:02 +0000
Subject: Re: QF, setting textarea value(?)
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8299@lists.php.net to get a copy of this message
<bmansion@mamasam.com> wrote: > <marba126@student.liu.se> wrote : > > Finally, two ideas: > > > > 1. What do you think about overriding the setConstants() (inherited from > > HTML_QF) in class HTML_QF_Page with something like: > > function setConstants($constantValues, $filters=null) { > > HTML_QuickForm::setConstants($constantValues, $filters=null); > > $this->controller->setConstants($constantValues); > > } > > This would make setConstant() to always put the values into the > (persistant) > > $_SESSION variable. Well, I know you generally recommend using the > > HTML_QF_Controller::setDefaults() for the sake of makeing a > single-page form > > look alike, but anyway... BTW, the same seems to apply to the setDefaults too. You can read in the documentation that: "It is perfectly legal to do call Page's setDefaults() from within buildForm()..." (see http://pear.php.net/manual/en/package.html.html-quickform-controller.intro.php) Shouldn't this also be reflected in the $_SESSION variable independed from where you setDefaults() from? > As you want to change the value of an element (your textarea) with the > content of another element (your uploaded file), I suggest acting directly > on the container values ($controller->container()), which > references element > values such as stored in the session. > > 1. Have a special index in the container called ['uploads'] > 2. If an upload is done, store a reference to the uploaded file in this > 'uploads' array. > 3. Check if this array is empty or not. > 4. If it's not empty, change the value of the container for your textarea > element. > Do all this in your action class. I suppose point 4 means I should update the textarea value according to (in my action class): $data =& $page->controller->container(); $data['values']['textarea_name'] .= $text_file_contents; Do I need the ['uploads'] index anyway? If I use it I must unset it so the file content dosen't append everytime I reload the pages after having done the file upload. > > I will make an example for that and other stuff like uploading images and > changing the content of a page based on the content of another page this > week. It will probably be available in CVS this week. > That would be great! I will see how you done it then! Let me know if I can help you by sending some cleaned up code to use as inspiration. > > Bertrand Mansion > Mamasam > A lot of thanks Markus

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