Re: Quickform group error
| From: | rav k | Date: | Fri, 08 Dec 2006 13:14:24 +0000 |
| Subject: | Re: Quickform group error | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26028@lists.php.net to get a copy of this message | ||
Thanks for that - it works..
www.bitesoftware.com - software for a better lifestyle
From: Alexey Borzov <borz_off@cs.msu.su> To: rav k <rav220@hotmail.com> CC: pear-general@lists.php.net Subject: Re: [PEAR] Quickform group error Date: Fri, 08 Dec 2006 16:11:49 +0300 MIME-Version: 1.0 Received: from imap.cs.msu.su ([212.192.248.39]) by bay0-mc8-f18.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Fri, 8 Dec 2006 05:10:17 -0800 Received: from [127.0.0.1] (oc.cmc.msu.ru [10.3.109.232])by imap.cs.msu.su (8.13.7/8.13.6) with ESMTP id kB8DAEvC064529(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);Fri, 8 Dec 2006 16:10:15 +0300 (MSK)(envelope-from borz_off@cs.msu.su) X-Message-Info: LsUYwwHHNt3660MmjhEvYg2f34OAemlK3oXsmRrh6gU= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060910 SeaMonkey/1.0.5 References: <BAY108-F2076729458CF31442D53979AD30@phx.gbl> X-Virus-Scanned: ClamAV 0.88.6/2305/Fri Dec 8 14:55:30 2006 on imap.cs.msu.su X-Virus-Status: Clean Return-Path: borz_off@cs.msu.su X-OriginalArrivalTime: 08 Dec 2006 13:10:17.0767 (UTC) FILETIME=[34F70B70:01C71ACA] Hi, rav k wrote:_________________________________________________________________ Windows Live Messenger has arrived. Click here to download it for free! http://imagine-msn.com/messenger/launch80/?locale=en-gbDo you mean clear the skills array in the while loop before adding the next one???No, I mean doing $skills = array(); before the while loop.Also can you explain why the error is caused in this case so we can troubleshoot this ourselves in the future :)If you have register_globals on (which *is* deprecated for quite a bit of time) then after the form submit you have a $skills array containing the submit values of your group. And then you append form elements to this array in your while loop. Then the group element iterates over its children expecting them to be instances of HTML_QuickForm_element and you get your "Call to a member function on a non-object" error.This is what I'm doin to dynamically add the skills as checkboxes: /* ADD THE SKILLS */ $res =& $mdb2->query('SELECT * FROM Skills'); while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {Turn off register_globals and/or clear the $skills array before adding form elements to it.$skills[] = &HTML_QuickForm::createElement('advcheckbox', $row['skillid'], null,'<b>'.$row['skillname'].'</b>'.' : '.$row['description']);} And I am adding them this way: $form->addGroup($skills, 'skills', 'Your skills:', '<br />'); The problem is I get the following error when attempting to validate: Fatal error: Call to a member function on a non-object in /home/user/public_html/iim/pear/PEAR/HTML/QuickForm/group.php on line 391 Can anyone please offer a solution to this??