Re: [PEPr] Comment on HTML::HTML_QuickForm_ElementTable
| From: | Fabio Ambrosanio | Date: | Fri, 26 May 2006 09:18:24 +0000 |
| Subject: | Re: [PEPr] Comment on HTML::HTML_QuickForm_ElementTable | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-42633@lists.php.net to get a copy of this message | ||
I want to return on the argument "exportValue":
1. I proposed to implement it like in group element and return
[elementTable] => Array ( <rows values> )
2. you said elementTable is not a group and exportValue have to return
Array ( <rows values> )
I'm agree with you, but I'm already using your class in a project and I
faces the need to have both cases, the first, if available, could make
my code more "clean" and readable.
So, what about to determinate exportValue behavior passing an option to
ElementTable's constructor?
Es.
|var $_options = array();
HTML_QuickForm_ElementTable($name = null, $label = null, $options = null) {
# a new field options can open future possibility
....
if (is_array($options)) $this->_options =
array_merge($this->_options, $options);
}
|
| function exportValue(&$submitValues, $assoc)
{
if ($this->_options('actAsGroup')) {
return parent::exportValue($submitValues, $assoc);
} else {
if ($assoc) {
$values = array();
foreach (array_keys($this->_rows) as $key) {
foreach (array_keys($this->_rows[$key]) as $key2) {
$value = $this->_rows[$key][$key2]->exportValue($submitValues, true);
if (is_array($value)) {
$values = array_merge($values, $value);
} else {
$values[$this->_rows[$key][$key2]->getName()] = $value;
}
}
}
return $values;
} else {
return null;
}
}
}|
Justin Patrin wrote:
> On 24 May 2006 08:37:04 -0000, Fabio Ambrosanio <fabio@ambrosanio.com>
> wrote:
>>
>> Fabio Ambrosanio (http://pear.php.net/user/fabamb) has commented on
>> the proposal for HTML::HTML_QuickForm_ElementTable.
>>
>> Comment:
>>
>> IMHO ...
>> I would have overloaded getvalue, only
>> In this way exportValues returns
>>
>> [elementTable] => Array ( <rows values> )
>>
>> and it can be useful if you want to have two or more tables with the
>> same
>> elements and obviously different names, like with group element
>>
>
> The elementTable is not supposed to be like a group. It is simply
> supposed to be a table holding other elements which already have their
> own names.
>
> It could possibly be a feature addition to make it behave like a group
> and add its own name to the names of its sub-elements, but I find this
> not particularly useful myself. I would suggest just adding any extra
> name you want straight into the name of the elements you add to the
> table.
>