RE: [PEAR-BUG] Bug #745 [Opn->Fbk]: ArraySmarty breaks without Group appendname - here is my fix
| From: | Harold LaRue | Date: | Fri, 13 Feb 2004 21:25:08 +0000 |
| Subject: | RE: [PEAR-BUG] Bug #745 [Opn->Fbk]: ArraySmarty breaks without Group appendname - here is my fix | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25652@lists.php.net to get a copy of this message | ||
Sure, here's the result of a QuickForm button group 'FormButtons' with
two elements added without the group name appended:
// From Page's BuildForm method...
// Form Buttons
$buttons = array();
$buttons[] =& $this->createElement('image',
$this->getButtonName('next'), 'images/button_add.png');
$buttons[] =& $this->createElement('submit',
$this->getButtonName('purge'), 'Purge');
$this->addGroup($buttons, 'FormButtons', '',
' ', false);
// Output from print_r($ret) just before returning $ret at end of
ArraySmarty _elementToArray method during the page rendering process:
Array
(
[name] => FormButtons
[value] => Array
(
[_qf_Transaction_purge] => Purge
)
[type] => group
[frozen] =>
[label] =>
[required] =>
[error] =>
[separator] =>
[html] => <input name="_qf_Transaction_next" type="image"
src="images/button_add.png" /> <input
name="_qf_Transaction_purge" value="Purge" type="submit" />
[keys] => ['FormButtons']
)
Array
(
[name] => _qf_Transaction_next
[value] =>
[type] => image
[frozen] =>
[label] =>
[required] =>
[error] =>
[html] => <input name="_qf_Transaction_next" type="image"
src="images/button_add.png" />
[keys] => on_next']
)
<br />
<b>Parse error</b>: parse error in
<b>/home/siegewer/includes/pear/HTML/QuickForm/Renderer/ArraySmarty.php(
242) : eval()'d code</b> on line <b>1</b><br />
Array
(
[name] => _qf_Transaction_purge
[value] => Purge
[type] => submit
[frozen] =>
[label] =>
[required] =>
[error] =>
[html] => <input name="_qf_Transaction_purge" value="Purge"
type="submit" />
[keys] => on_purge']
)
<br />
<b>Parse error</b>: parse error in
<b>/home/siegewer/includes/pear/HTML/QuickForm/Renderer/ArraySmarty.php(
242) : eval()'d code</b> on line <b>1</b><br />
> -----Original Message-----
> From: PHP Bug Database [mailto:pear-dev@lists.php.net]
> Sent: Friday, February 13, 2004 4:19 AM
> To: hlarue@siegewerks.com
> Subject: [PEAR-BUG] Bug #745 [Opn->Fbk]: ArraySmarty breaks
> without Group appendname - here is my fix
>
>
> ATTENTION! Do NOT reply to this email!
> To reply, use the web interface found at
> http://pear.php.net/bugs/bug.php?id=745&edit=2
>
>
> ID: 745
> Updated by: ths@php.net
> Reported By: hlarue at siegewerks dot com
> -Status: Open
> +Status: Feedback
> Bug Type: HTML_QuickForm
> Operating System: Linux
> PHP Version: 4.3.3
> -Assigned To:
> +Assigned To: ths
> New Comment:
>
> I removed such check from code because I saw no reason for
> it.. Can you
> please send an piece of code, that show these "killing the rendering
> process"?
>
>
>
> If so I will add these additional check:
>
>
>
> if (0 === strpos($sKeys, $this->_currentGroup['keys'])) {
>
> $sKeys = substr_replace($sKeys, '', 0,
> strlen($this->_currentGroup['keys']));
>
> }
>
>
>
>
>
> Thank you.
>
>
>
>
>
>
> Previous Comments:
> --------------------------------------------------------------
> ----------
>
> [2004-02-12 18:34:03] hlarue at siegewerks dot com
>
> Description:
> ------------
> Found that my button groups were killing the rendering process when I
> chose not to append the groupnames to the elements. ArraySmarty was
> removing the beginning of the key name, expecting to remove the group
> name, whether it existed or not...
>
>
>
> Here's my temporary fix and my thanks for all of your great work!
>
>
>
> Cheers!
>
>
>
> Reproduce code:
> ---------------
> // special handling for elements in native groups
>
> if ($this->_currentGroup) {
>
> // skip unnamed group items unless radios: no name ->
> no static access
>
> // identification: have the same key string as the
> parent group
>
> if ($this->_currentGroup['keys'] == $sKeys and 'radio'
> != $ret['type']) {
>
> return false;
>
> }
>
> // reduce string of keys, ** IF NECESSARY **, by
> remove leading group keys
>
> if (strpos($sKeys, $this->_currentGroup['keys']) !==
> false) {
>
> $sKeys = substr_replace($sKeys, '', 0,
> strlen($this->_currentGroup['keys']));
>
> }
>
> }
>
>
>
>
>
> --------------------------------------------------------------
> ----------
>
>
>