سؤال

I am rendering a very simple form with a table format. I first add the elements, to later set their basic decorators with the following:

$this->setElementDecorators(array(
        'Viewhelper',
        array(array('data'=>'HtmlTag'),array('tag'=>'td')),
        'Label',
        array(array('labelCell'=>'HtmlTag'),array('tag'=>'td', 'align'=>'right')),
        array(array('row'=>'HtmlTag'), array('tag'=>'tr'))
    ));

Afterwards, I manipulate whatever group of elements (as desired) to set up different looks, like: group elements in a single row. To do this last one, the following is carried out:

$this->getElement($elementName)->setDecorators(array(
        'Viewhelper',
        array(array('data' => 'HtmlTag'), array('tag' => 'td', 'colspan' => $colspan)),
        'Label',
        array(array('labelCell' => 'HtmlTag'), array('tag' => 'td', 'align' => 'right')),
        array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
    ));

As you see, I have to setDecorators() adding all of them (the default ones) again, so I can change the 'data' decorator and add the attribute "colspan".

My question would be: is it possible to access and change a single decorator without having to set all of the previous decorators the element had?

هل كانت مفيدة؟

المحلول

you should be able to call:

$viewHelperDecorator = $this->getElement($elementName)->getDecorator('ViewHelper');

Then, this is like any other decorator (it is a decorator abstract) - so you can call

$viewHelperDecorator->setOption();

and set the change you'd like.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top