• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

Default value for PEAR::QuickForm::Textarea

Is there a way to set the defasutl value for a textbox created with PEAR's Quickform? The inherited method setValue doesn't work since the textarea-tag doesn't respond to the value-attribute...

Thanks in advance,
//madwax
0
madwax
Asked:
madwax
  • 2
1 Solution
 
hernst42Commented:
Setting the value via setValue should work as the PHP-Code which outputs the textarea is the following:
 preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value))

and the settings is done vi
    function setValue($value)
    {
        $this->_value = $value;
    } //end func setValue

version I looked in HTML_QuickForm-3.2.3

So it should work.
0
 
madwaxAuthor Commented:
hmm... maybe I am doing something wrong then.... I have upgraded pear with the upgrade-all command and on the page I have the following code (excerpt):

$form->addElement('textarea', 'long_description','Beskrivning:', array('cols' => 50, 'rows' => 15, 'value' => "test1"));
$ld = $form->getElement("long_description");
$ld->setValue("test");

it doesn't display any value in the textarea and when I print_r($ld) i get:

html_quickform_textarea Object ( [_attributes] => Array ( [cols] => 50 [rows] => 15 [value] => test1 [name] => long_description ) [_tabOffset] => 0 [_tab] => [_lineEnd] => [_comment] => [_label] => Beskrivning: [_type] => textarea [_flagFrozen] => [_persistantFreeze] => 1 [_value] => test )

this clearly shows that the _value variable is set both once And twice but isn't showed any of the times... (it doesn't work without the $ld) either...

//madwax
0
 
hernst42Commented:
So I got the error. THe problem ist that you modify a copy of your text-area-object, but not the object in the QuickForm. Change the line:
$ld = $form->getElement("long_description");
to
$ld = &$form->getElement("long_description");

and it works.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now