SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem of QuickForm

    Hi and Sorry...
    Because that i am a chinese so my english is not good.

    When i run 6.php of chapter "AccessControl" , I got a error message ---
    Fatal error: Call to undefined method HTML_QuickForm::clearAllTemplates() in D:\Apache2\htdocs\AccessControl\6.php on line 76

    I found there is a problem in 6.php of directory witch is named AccessControl.
    ex:
    PHP Code:
        // Instantiate the QuickForm class
        
    $form = new HTML_QuickForm('regForm''POST');

        
    // Clear the default HTML templates
        
    $form->clearAllTemplates();

        
    // Define new templates
        
    $form->setFormTemplate('
    <table class="registration">
      <form{attributes}>{content}
      </form>
    </table>'
    );
    .
    .

    When i check the code of QuickForm.php , i found there is no such these clearAllTemplates() , setFormTemplate() ...method defined in class "HTML_QuickForm".

    (The package "HTML_QuickForm" i haved installed is version of 3.2.5)

  2. #2
    SitePoint Wizard silver trophy Bleys's Avatar
    Join Date
    Feb 2003
    Location
    RI-USA
    Posts
    5,620
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I moved this to the PHP forum as I think you'll get a better response here (and that's where it belongs ).
    Josh is a ghost
    rails & work & twitter

    Organization is the
    death of creativity.

  3. #3
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    QuickForm has had a few changes since that book was published. I think if you create an instance of the default renderer and call the clearAllTemplates method on that, it should work fine for you. Here is an example from the PEAR::HTML_QuickForm website I've extended to illustrate the required change.

    PHP Code:
    require_once('HTML/QuickForm.php');
    $form = new HTML_QuickForm('myform');

    $renderer =& $form->defaultRenderer();

    // Clear the default HTML templates
    $renderer->clearAllTemplates();

    // Define new templates
    $renderer->setFormTemplate('<table class="myForm">
    <form{attributes}>{content}
    </form>
    </table>'
    );

    $renderer->setHeaderTemplate('<th>{header}</th>');

    $renderer->setElementTemplate('<tr>
    <td><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{label}</td>
    <td>{element}</td>
    </tr>'
    );

    // Add some elements to the form
    $form->addElement('header'null'QuickForm tutorial example');
    $form->addElement('text''name''Enter your name:', array('size' => 50'maxlength' => 255));
    $form->addElement('submit'null'Send');

    // Define filters and validation rules
    $form->applyFilter('name''trim');
    $form->addRule('name''Please enter your name''required'nullfalse);

    // Try to validate a form
    if ($form->validate()) {
    echo 
    '<h1>Hello, ' htmlspecialchars($form->exportValue('name')) . '!</h1>';
    exit;
    }

    $form->accept($renderer);
    $form->display(); 
    Here is a list of links that may be usefull in your QuickForm endeavours:
    http://www.phpkitchen.com/index.php?...Tutorials.html

    Cheers;
    Poncho
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  4. #4
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for your reply.

    Q1:
    > pear uninstall HTML_QuickForm-3.2.5
    > pear install HTML_QuickForm-3.1.1
    After the two thing writen above i did , it was successfull when i run 6.php again.

    In order to test, i did two action writen below:
    > pear uninstall HTML_QuickForm-3.1.1
    > pear install HTML_QuickForm-3.2.5
    It was successfull too when i run 6.php again.

    .....Why??



    Q2:
    Although i have run 6.php successfully ,i still be interest about the content of your reply.

    What is the code on this line of your last reply mean?
    PHP Code:
    $renderer =& $form->defaultRenderer(); 


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
  •