Re: QF, setting textarea value(?)
| From: | Markus | Date: | Mon, 06 Oct 2003 00:11:01 +0000 |
| Subject: | Re: QF, setting textarea value(?) | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-8282@lists.php.net to get a copy of this message | ||
Thanks Bertrand, think you got me onto the right track! (This resulted in a
thougt about the HTML_QF_Page::setConstants(), see the last rows.)
I've just realized I left out some (most likely) highly relevant information
in my first description of the problem. Using HTML_QF->setConstants() will
most probably do the trick if the form is created with the QF-package only.
However this isn't actually true in my case. The form I use is bulit with
the QF_Controller-package.
I perform the reloading of my page (named "text_page") by pushing the button
generated on the line...
$this->addElement('submit', $this->getButtonName('text_page'),
'Append
file to text');
...in the text_page's class extending class HTML_QF_Page.
Clicking that submit button fires a "Direct"-action defined by:
$my_multi_page_form->addAction('text_page', new
HTML_QF_Action_Direct());
After some serious investigations of the QF_Controller-package's code ...
Using the 'direct'-action internally results in a 'jump'-action. This in
turn results in new header information being sent which makes a new request
to 'display' the text_page (reload it). Thus using HTML_QF::setConstants()
won't work because the constants ain't saved in the $_SESSION variable till
the 'display'-request.
Nonetheless, it works using HTML_QF_Controller::setConstants() which do save
the constants in the $_SESSION variable. BUT there is a drawback with the
use of HTML_QF_Controller::setConstants() - I must unset it every time I
don't upload the text file because I still want to be able to edit the text.
Guess I've to that "manually" because there isn't any unsetConstants(), is
it?
Or I have to use a customized action that make use of the
HTML_QF_Action_Display directly. Haven't tried of this variant yet.
Phu... Hope you got an idea of the problem otherwise please feel free to ask
for a better explanation. That would certainley be motivated ;)
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...
2. Some kind of updateSubmitValues() method would be useful, at least in
this case (but maybe in other cases too). This would override both submitted
and default values but not constant values. Maybe this can already be done
with som filter-funtionallity?
Thanks a lot!
Markus
<bmansion@mamasam.com> wrote :
>
> <marba126@student.liu.se> wrote :
>
> > Hi!
> >
> > I have a textarea and a file element in my form. I want to the
> content of
> > the text file that has been uploaded, to append to the content of the
> > textarea.
> >
> > The only way I've managed to do this is by concatenating the
> contents of the
> > file directly to the _submitValues[...] variable of the
> QF-object. However,
> > I suppose this isn't a preferred way because I have to use a "private"
> > variable.
> >
> > I've tried using the setValue() method of the textarea-object and
> > updateElementAttr() as well as the updateAttributes() method of the
> > QF-object. Unfortenately, all these seems to get overridden by
> the submitted
> > values when "reloading" the form.
> >
> > By the way, the HTML textarea dosen't really have an 'value'
> attribute, has
> > it? Could that be the reason why updateElementAttr() and
> updateAttributes()
> > fails? Nonetheless, the quickform-element textarea does have an
> attribute
> > 'value' that you can operate upon with setValue()/getValue().
> This might be
> > a bit missleading maybe.
> >
> >
> > Any help to sort things out here is greatly appreciated! I
> might very well
> > be missing some fundamentals.
>
> You can use setConstants(), it overides both default values
> (setDefaults())
> and submitted values.
>
> BTW, in a textarea element, there in no value attribute as its content is
> the data between the tags.
>
> Bertrand Mansion
> Mamasam
>
>