and this is the workaround code (yek!):
/**
* Retrieve a registered decorator
*
* @param string $name
* @return false|Zend_Form_Decorator_Abstract
*/
public function getDecorator($name)
{
//this is what I added:
$decorators = $this->getDecorators();
return $decorators[$name];
//this is what you can throw away for now:
/* if (!isset($this->_decorators[$name])) {
$len = strlen($name);
foreach ($this->_decorators as $localName => $decorator) {
if ($len > strlen($localName)) {
continue;
}
if (0 === substr_compare($localName, $name, -$len, $len,
true)) {
if (is_array($decorator)) {
return $this->_loadDecorator($decorator,
$localName);
}
return $decorator;
}
}
return false;
}
if (is_array($this->_decorators[$name])) {
var_dump($this->_decorators[$name]);
return $this->_loadDecorator($this->_decorators[$name], $name);
}
return $this->_decorators[$name];
*/
}
Bart McLeod schreef:
here's a workaround:
$decorators = $this->getElement('delete')->getDecorators();
$td = $decorators['td'];
$td->setOption('colspan', '3');
So you get all decorators, since that is not buggy, extract the one
you need and set the options you need.
So getDecorator() can be rewritten to do this then... for now.
Bart
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