0
votes

I subclass Zend_Form to allow re-use as I describe in my other SO question. It's working very well, except for one issue that I found. In my view script I use this code to render the label for fields:

echo $this->formLabel($this->element->getFullyQualifiedName(),
        $this->element->getLabel());

The rendered label has the original element id as the value in the for attribute rather than the new, suffixed, element id. Is there a bug in the Zend code, am I missing a step or doing something incorrectly?

1
Can you show how exactly and in which method (!) you've implemented new, suffixed id? - Radek Benkel
If you visit the other question that I linked to, you'll see the code. I added a function for setting the suffix, and have overridden the render() function. - Sonny

1 Answers

3
votes

I think the reason is that you use formLabel view helper independently. As a result, the helper is not aware of any attributes that you specified for your input text field. So, you should provide these attributes to the formLabel. For example you could do the following:

echo $this->formLabel(
        $this->element->getFullyQualifiedName(),
        $this->element->getLabel(),
        $this->element->getAttribs() 
);

The above code should produce for tag that matches your input elements id. Otherwise, the for tag will be set to the elements name.