SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PEAR addElement() not accepting content

    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:
    Code:
    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,
    Code:
    addElement()
    requires an array to be passed as the last argument. What's wrong here?
    Guidance please!

  2. #2
    SitePoint Evangelist speda1's Avatar
    Join Date
    Jan 2002
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    C:\my_server_dir\phpQuickForm\HTMLForm.php on line 7 isn't passing an array as argument 4 into addElement().

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by speda1 View Post
    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

    Code:
       $form = new HTML_QuickForm('Create', 'post', basename(__FILE__));
      
      // Our Default Form Options
      $opts = array('size' => 20, 'maxlength' => 255);
    
      // Add our form elements
      $form->addElement('static', 'header', null, 
          '<h1>Register</h1>'
      );
    So I guess my question is:

    -Is the code from the book not updated or did I do something wrong at installation?

    Thanks

  4. #4
    SitePoint Member
    Join Date
    Dec 2012
    Location
    Edmonton Canada
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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/packag...-migration.php

    Have fun, be patient - I'm learning the hard way too!!!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •