Question

I am trying to make custom decorators and I came to an issue. Below is my code:

$oElement->setDecorators(array(
    'ViewHelper',
    array(array( 'data' => 'HtmlTag'),
    array('tag' => 'dd', 'span' => 'myspan', 'class' => $class . ' myclass ' )),
    array('Label', array('tag' => 'dt', 'class' => $class))
));

I want to add a span inside the dd so that after rendering the form it looks like:

<dd class="myclass"> <span> </span> </dd>

What am I missing here?

Was it helpful?

Solution

I can't test this as don't have Zend installed on my tablet, but think you have to add the span:

$oElement->setDecorators(array(
    'ViewHelper',
    array(array('data' => 'HtmlTag'), 
        array('tag' => 'span', 'class' => $class . 'myspan')),
    array(array('span'   => 'HtmlTag'), 
        array('tag' => 'dd', 'class' => $class . 'myclass')),
    array('Label', array('tag' => 'dt', 'class' => $class))
));

I remember getting fed up with Zend decorators personally and Zend Forms in general as it felt like it took more effort than just making forms in HTML. Hope this helps anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top