public function getElementIndex($elementName)
{
$name = null;
$elem = null;
$index = null;
$elems = $this->form->getChildren();
foreach ($elems as $i => $e) {
if ($e->getNodeName() == 'fieldset') {
$children = $e->getChildren();
foreach ($children as $c) {
if ($c->getNodeName() == 'input') {
$attribs = $c->getAttributes();
$name = str_replace('[]', '', $attribs['name']);
}
}
} else {
$attribs = $e->getAttributes();
$name = $attribs['name'];
}
if ($name == $elementName) {
$index = $i;
}
}
return $index;
}