I should have paid more attention to the errors that I was getting.  They
gave me the road map to extending DisplayGroup properly.  By extending
Zend_Form_DisplayGroup and including the following methods, I was able to
successfully apply a label to a DisplayGroup:

  public function setLabel($label) {
      return $this->setAttrib('label', (string) $label);
  }

  public function getLabel() {
      return $this->getAttrib('label');
  }
  
  public function setRequired($flag) {
      $this->_required = (bool) $flag;
      return $this;
  }

  public function isRequired() {
      return $this->_required;
  }


jkendall wrote:
> 
> By default, a display group is wrapped in a Fieldset, allowing for a
> legend at the top of your display group.  I have a use case where I'd like
> to wrap the display group in li tags and add a label at the top:
> 
> <li>
> 
>     <label>Blah</label>
> 
>     DISPLAY GROUP
> 
> </li>
> 
> Attempting to add a Label element to a display group results in the
> following error: Call to undefined method
> Zend_Form_DisplayGroup::getLabel() in Zend/Form/Decorator/Label.php on
> line 242.
> 
> Subclassing DisplayGroup and adding a getter and setter for Label results
> in: Call to undefined method SJCRH_Form_DisplayGroup::isRequired() in
> Zend/Form/Decorator/Label.php on line 260.
> 
> Obviously, I'm missing something in regards to DisplayGroup and how it
> relates to Decorators, but I can't seem to figure it out.  Any help?
> 


-----
Jeremy Kendall --  http://www.jeremykendall.net http://www.jeremykendall.net 
-- 
View this message in context: 
http://www.nabble.com/Zend-Form%3A-Trying-to-add-a-Label-Decorator-to-a-DisplayGroup-tp18097521p18112606.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to