PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #5176

Cannot set attributes for textareas (in PHP4)

Details

Submitted2005-08-22 21:22 UTC
Fromdf at india dot com
StatusBogus
PackageHTML_QuickForm
PHP Version4.3.7
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-08-22 21:22 UTC] df at india dot com

Description:
------------
HTML_QuickForm API Version 3.2

Works for PHP 5.02, but not PHP 4.3.7

Note: I am using Pear's Dataobject Formbuilder, but it shouldn't matter.

After adding a "textarea" input to a form (formbuilder does this for me), I try to modify the size of it with the 'cols' and 'rows' tag attributes.

This works with PHP5, but not on my production server with PHP4. In PHP4, it simply does not output the HTML for those tag attributes.

Test script:
---------------
$project = DB_DataObject::factory('projects');
$project->get('3');

$fb = & DB_DataObject_FormBuilder::create($project);
$form= & $fb->getForm();

$e = $form->getElement('summary');
$e->_attributes['cols'] = 30;
$e->_attributes['rows'] = 7;

echo $form->toHtml();

Expected result:
----------------
<textarea name="summary" cols="30" rows="7">My summary</textarea>

(Does this in PHP5)

Actual result:
--------------
<textarea name="summary">My summary</textarea>

(Does this in PHP4)

[2005-08-22 22:16 UTC] bmansion at mamasam dot com

1. In PHP5, an object is returned by reference. In PHP4, it is copied. So use & like in $e =& $form->getElement('summary');

2. Don't access $_attributes directly, use updateAttributes() from HTML_Common. Variables prefixed with _ are considered private so don't play with them.