Hello,
I see what you are talking about. But I wasn't proposed to remove
unset($options['options']);
But make it a little bit more compatible with ViewHelper, as the
last one is getting $element->options property. So, for example,
I can set this property directly inside init() method of my custom
element. Or directly on element as I showed in my previous message.
So that's why I was proposing to replace:
unset($options['options']);
with:
if (array_key_exists('options', $options)) {
$this->options = $options['options'];
unset($options['options']);
}
7 февраля 2010 г. 14:42 пользователь Александр Шелковский
<[email protected]> написал:
> Hello.
>
> I think it is not a bug , it is feature or it is just how it works.
>
> Some coder here:
>
>> unset($options['options']); <-- place about you are talking
>> unset($options['config']);
>>
>> foreach ($options as $key => $value) {
>> $method = 'set' . ucfirst($key);
>>
>> if (in_array($method, array('setTranslator',
>> 'setPluginLoader', 'setView'))) {
>> if (!is_object($value)) {
>> continue;
>> }
>> }
>>
>> if (method_exists($this, $method)) {
>> // Setter exists; use it
>> $this->$method($value); <-- here is a problem if not unset
>> options or config we have a problem ) Just calling setOptions method of the
>> class again and again.
>> } else {
>> // Assume it's metadata
>> $this->setAttrib($key, $value);
>> }
>> }
>> return $this;
>
> So you should not use options use something else:
> $form->addElemen('myElement', 'my_name', array(
> 'label' => 'My Label',
> 'test' => array(
> 'argument' => 'for my view helper'
> )
> ));
>
> $formt->getElement(...)->getAttrib('test');
>
>
--
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 617 179 344
Homepage: http://www.ixti.ru
JID: [email protected]
*Origin: Happy Hacking!