another addition:
The problem is in the new getDecorator function. If you call it, it 'lazyloads' the decorator, but puts it at the end of the stack. See this output, where I var_dumped the decorators inside the lazy load function, before and after getting the decorator 'td': In the first array of 7 decorators, td is between errors and tr, where it should be. In the second array, it comes after table, effectively breaking the rendering chain.

       loading td
array(7) {
 ["ViewHelper"]=>
 array(2) {
   ["decorator"]=>
   string(10) "ViewHelper"
   ["options"]=>
   NULL
 }
 ["div"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   NULL
 }
 ["Label"]=>
 array(2) {
   ["decorator"]=>
   string(5) "Label"
   ["options"]=>
   NULL
 }
 ["Errors"]=>
 array(2) {
   ["decorator"]=>
   string(6) "Errors"
   ["options"]=>
   NULL
 }
 ["td"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   array(2) {
     ["tag"]=>
     string(2) "td"
     ["valign"]=>
     string(3) "top"
   }
 }
 ["tr"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   array(3) {
     ["tag"]=>
     string(2) "tr"
     ["openOnly"]=>
     bool(true)
     ["placement"]=>
     string(7) "prepend"
   }
 }
 ["table"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   array(5) {
     ["cellspacing"]=>
     string(1) "0"
     ["cellpadding"]=>
     string(1) "3"
     ["tag"]=>
     string(5) "table"
     ["openOnly"]=>
     string(4) "true"
     ["placement"]=>
     string(7) "prepend"
   }
 }
}
array(7) {
 ["ViewHelper"]=>
 array(2) {
   ["decorator"]=>
   string(10) "ViewHelper"
   ["options"]=>
   NULL
 }
 ["div"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   NULL
 }
 ["Label"]=>
 array(2) {
   ["decorator"]=>
   string(5) "Label"
   ["options"]=>
   NULL
 }
 ["Errors"]=>
 array(2) {
   ["decorator"]=>
   string(6) "Errors"
   ["options"]=>
   NULL
 }
 ["tr"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   array(3) {
     ["tag"]=>
     string(2) "tr"
     ["openOnly"]=>
     bool(true)
     ["placement"]=>
     string(7) "prepend"
   }
 }
 ["table"]=>
 array(2) {
   ["decorator"]=>
   string(7) "HtmlTag"
   ["options"]=>
   array(5) {
     ["cellspacing"]=>
     string(1) "0"
     ["cellpadding"]=>
     string(1) "3"
     ["tag"]=>
     string(5) "table"
     ["openOnly"]=>
     string(4) "true"
     ["placement"]=>
     string(7) "prepend"
   }
 }
 ["td"]=>
 object(Zend_Form_Decorator_HtmlTag)#191 (6) {
   ["_placement:protected"]=>
   NULL
   ["_tag:protected"]=>
   NULL
   ["_tagFilter:protected"]=>
   NULL
   ["_element:protected"]=>
   NULL
   ["_options:protected"]=>
   array(2) {
     ["tag"]=>
     string(2) "td"
     ["valign"]=>
     string(3) "top"
   }
   ["_separator:protected"]=>
   string(2) "
"
 }
}

Bart McLeod schreef:
In addition to this, I just tried to break a few more elements. Their is a checkbox in my table. If I call: $this->getElement('in_mainmenu')->getDecorator('td')->setOption('colspan',2); Then the td is appended as a whole, an no longer wrapped! The colspan attrib is right there:

<td valign="top" colspan="2"></td>
<input type="hidden" name="in_mainmenu" value="0"><input type="checkbox" name="in_mainmenu" id="in_mainmenu" value="1">

but the closing td should wrap!
If I do not set the colspan attrib, I get what it should be and what it was like before I updated from svn: <td valign="top"><label for="in_mainmenu" class="optional">in navigatie</label>
<div>
<input type="hidden" name="in_mainmenu" value="0"><input type="checkbox" name="in_mainmenu" id="in_mainmenu" value="1"></div></td>

You can see here that the td also moved passed label and div towards the checkbox (in the first HTML sample)! Note that I do not re-ad the decorator to the stack, I just call upon its reference to set an option.

Any help appreciated. I start to think this is a bug and I will revert to the old element.php

Regards,

Bart McLeod


Bart McLeod schreef:
Hi all, and Matthew in particular,

First of all, sorry to bother you all if I missed some earlier messages about this. It's just I am at a deadline and need quick insight.

I use pretty complex forms using table decorators, rows, td's an so on. Tables shouldn't be used for formatting, I know, and I don't really care: they'r useful.

To manage al this complexitity I used a fairly simple set of rules, that can be handed over to a formbuilder, which then builds the form based on those rules.

What the builder does is put al elements with all they decorators in a table cell, group those in a row and group all rows in a table.

In some cases, a row contains more cells than another and I use the colspan attribute to fill the gap.

I had this working until I upgraded 5 minutes ago from svn.

Now what changed, is that if I want to set an option on a decorator, say I want to set the option colspan=2 on the last table cell, the decorators just break... For example, openOnly does not work anymore, although it is being set along with other settings that do work.

I believe something changed in the way elementDecorators are applied. If I set an option after applying elementDecorators, the order of the decorators seems to change. If I just leave the decorators in place and change none of their options everything is fine, but if I pull them out and set an option, they get a different position in the rendering chain. At least, that is what it looks like to me.

Anyone knows what may have caused this? Know a workaround, fix, other approach that does work?

Regards,

Bart McLeod



Reply via email to