It failed because I'm adding elements like $this->addElement($brand); and
name is not provided, this way, you take name from element:
public function addElement($element, $name = null, $options = null) {
if (!is_array($options)) {
$options = array();
}
// A plugin loader is implicitly created if default decorators are
loaded
$options['disableLoadDefaultDecorators'] = true;
// Add the element to the form
parent::addElement($element, $name, $options);
// Configure the element to use the form's plugin loaders
$element = $this->getElement($element->getName());
foreach ($this->_loaders as $type => $loader) {
if ($type != 'ELEMENT') {
$element->setPluginLoader($loader, $type);
}
}
// Now load default decorators for the element
$element->loadDefaultDecorators();
return $this;
}
Does this works faster for someone?
Regards,
Saša Stamenković
On Wed, Sep 30, 2009 at 3:36 PM, holografix . <[email protected]> wrote:
> Hi
> Can you post your solution here ?
>
> Cheers
> holo
>
>
> 2009/9/30 Саша Стаменковић <[email protected]>
>
>> Made this method work, form is now 3 times slower :(
>>
>> Regards,
>> Saša Stamenković
>>
>>
>>
>> On Wed, Sep 30, 2009 at 11:49 AM, Саша Стаменковић <[email protected]>wrote:
>>
>>> Tried to add
>>> public function addElement($element, $name = null, $options = null)
>>> {
>>> if (!is_array($options)) {
>>> $options = array();
>>> }
>>>
>>> // A plugin loader is implicitly created if default decorators
>>> are loaded
>>> $options['disableLoadDefaultDecorators'] = true;
>>>
>>> // Add the element to the form
>>> parent::addElement($element, $name, $options);
>>>
>>> // Configure the element to use the form's plugin loaders
>>> $element = $this->getElement($name);
>>> foreach ($this->_loaders as $type => $loader) {
>>> if ($type != 'ELEMENT') {
>>> $element->setPluginLoader($loader, $type);
>>> }
>>> }
>>>
>>> // Now load default decorators for the element
>>> $element->loadDefaultDecorators();
>>>
>>> return $this;
>>> }
>>>
>>> to my form.
>>>
>>> It says :
>>>
>>> *Fatal error*: Call to a member function setPluginLoader() on a
>>> non-object in
>>> this line:
>>> $element->setPluginLoader($loader, $type);
>>>
>>> Regards,
>>> Saša Stamenković
>>>
>>>
>>>
>>> On Wed, Sep 30, 2009 at 9:24 AM, keith Pope <[email protected]>wrote:
>>>
>>>> You may want to look at this:
>>>>
>>>> http://ishouldbecoding.com/tag/zend-framework
>>>>
>>>> Theres a post about Zend_Form and the Pluginloader, it shows a way to
>>>> reduce the amount of plugin loader instances.
>>>>
>>>> 2009/9/30 Саша Стаменковић <[email protected]>:
>>>> > But he can cache rendered content, then time will be spent just on
>>>> pulling
>>>> > html from cache (shooting in the dark) ;)
>>>> > I would try both and do some benchmarking - plz share the results.
>>>> >
>>>> > Regards,
>>>> > Saša Stamenković
>>>> >
>>>> >
>>>> > On Wed, Sep 30, 2009 at 8:25 AM, Peter Warnock <[email protected]
>>>> >
>>>> > wrote:
>>>> >>
>>>> >> I would only cache if it's visibly slow, or you're running out of
>>>> memory.
>>>> >> If you're going to cache, cache the output since most of the overhead
>>>> is
>>>> >> used in rendering. Keep in mind, you lose the ability to pre-populate
>>>> the
>>>> >> form.
>>>> >> - pw
>>>> >>
>>>> >> On Mon, Sep 28, 2009 at 4:49 AM, holografix . <[email protected]>
>>>> >> wrote:
>>>> >>>
>>>> >>> Hi
>>>> >>>
>>>> >>> I have several complex forms in the application and I would like to
>>>> know
>>>> >>> if there is any benefit in caching those forms.
>>>> >>> If so, what would be the best way to go? Cache the classes or the
>>>> output
>>>> >>> of the forms?
>>>> >>>
>>>> >>> Cheers
>>>> >>> holo
>>>> >>
>>>> >
>>>> >
>>>>
>>>
>>>
>>
>