Hello there,
I’m trying to create my first form using PEAR QuickForm2, following the PHP Anthology SP book. Now my php server gives me this error:
Catchable fatal error: Argument 4 passed to HTML_QuickForm2_Container::addElement() must be an array, string given, called in C:\\my_server_dir\\phpQuickForm\\HTMLForm.php on line 7 and defined in C:\\php\\PEAR\\HTML\\QuickForm2\\Container.php on line 246
I checked the Container.php file of QuickForm and is correct,
addElement()
requires an array to be passed as the last argument. What’s wrong here?
Guidance please!
C:\my_server_dir\phpQuickForm\HTMLForm.php on line 7 isn’t passing an array as argument 4 into addElement().
Thank you and I get that the script is not passing an array as the foruth argument, which is required by the addElement() function. So this is the code
$form = new HTML_QuickForm('Create', 'post', basename(__FILE__));
// Our Default Form Options
$opts = array('size' => 20, 'maxlength' => 255);
// Add our form elements
[B]$form->addElement('static', 'header', null,
'<h1>Register</h1>'
);[/B]
So I guess my question is:
-Is the code from the book not updated or did I do something wrong at installation?
Thanks
The arguments from QuickForm2 are different than QuickForm. Check the documentation on PEAR site to see the differences. There is a section there that explains the difference.
Here is a link to page which shows examples:
http://pear.php.net/manual/en/package.html.html-quickform2.qf-migration.php
Have fun, be patient - I’m learning the hard way too!!!