Re: [fw-general] Zend Form: Trying to add a Label Decorator to a DisplayGroup

2009-11-06 Thread umpirsky

Yes, or

$this-addDisplayGroup(
array(
'e1',
'e2'
),
'name',
array(
'displayGroupClass' = 'My_Form_DisplayGroup'
)

But I get:

Warning: Exception caught by form: Method getType does not exist Stack
Trace: #0 [internal function]: Zend_Form_DisplayGroup-__call('getType',
Array) #1 /usr/local/share/pear/Zend/Form/Decorator/ViewHelper.php(92):
Lib_Form_DisplayGroup-getType() #2
/usr/local/share/pear/Zend/Form/Decorator/ViewHelper.php(233):
Zend_Form_Decorator_ViewHelper-getHelper() #3
/usr/local/share/pear/Zend/Form/DisplayGroup.php(874):
Zend_Form_Decorator_ViewHelper-render('') #4
/usr/local/share/pear/Zend/Form/Decorator/FormElements.php(101):
Zend_Form_DisplayGroup-render() #5
/usr/local/share/pear/Zend/Form.php(2626):
Zend_Form_Decorator_FormElements-render('') #6
/usr/local/share/pear/Zend/Form.php(2641): Zend_Form-render() #7
/usr/local/www/svn.loopia.se/controlweb/umpirsky.test.af.loopia.se/application/views/scripts/userinfo/index.phtml(18):
Zend_Form-__toString() #8 /usr/local/share/pear/Zend/View.php(108):
include('/usr/local/www/...') #9
/usr/local/share/pear/Zend/View/Abstract.php(833):
Zend_View-_run('/usr/local/www/...') #1 in
/usr/local/share/pear/Zend/Form.php on line 2646

My class:

class My_Form_DisplayGroup extends Zend_Form_DisplayGroup {
public function loadDefaultDecorators() {
if ($this-loadDefaultDecoratorsIsDisabled()) {
return;
}

 $this-setDecorators(
array(
'ViewHelper',
array(array('td' = 'HtmlTag'), array('tag' = 
'td', 'style' = 'width:
360px;')),
array('Label', array('tag' = 'td', 
'requiredSuffix' = ' *')),
array(array('tr' = 'HtmlTag'), array('tag' = 
'tr')),
array(array('tbody' = 'HtmlTag'), array('tag' 
= 'tbody')),
array(array('table' = 'HtmlTag'), array('tag' = 
'table', 'class' =
'tiny')),
array(array('separator' = 'HtmlTag'), array('tag' 
= 'div', 'class'
= 'separator'))
)
);
}

}

Any idea?



Tim Fletcher wrote:
 
 It took me long time to work out that in order to subclass
 Zend_Form_DisplayGroup, you must set the class appropriately. If you're
 creating your form by subclassing Zend_Form you should use : 
 
 $this-setDefaultDisplayGroupClass('App_Form_DisplayGroup');
 

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



Re: [fw-general] Zend Form: Trying to add a Label Decorator to a DisplayGroup

2009-11-06 Thread Саша Стаменковић
Ah, wrong decorators - fixed!

Regards,
Saša Stamenković


On Fri, Nov 6, 2009 at 9:20 AM, umpirsky umpir...@gmail.com wrote:


 Yes, or

 $this-addDisplayGroup(
array(
'e1',
'e2'
),
'name',
array(
'displayGroupClass' = 'My_Form_DisplayGroup'
)

 But I get:

 Warning: Exception caught by form: Method getType does not exist Stack
 Trace: #0 [internal function]: Zend_Form_DisplayGroup-__call('getType',
 Array) #1 /usr/local/share/pear/Zend/Form/Decorator/ViewHelper.php(92):
 Lib_Form_DisplayGroup-getType() #2
 /usr/local/share/pear/Zend/Form/Decorator/ViewHelper.php(233):
 Zend_Form_Decorator_ViewHelper-getHelper() #3
 /usr/local/share/pear/Zend/Form/DisplayGroup.php(874):
 Zend_Form_Decorator_ViewHelper-render('') #4
 /usr/local/share/pear/Zend/Form/Decorator/FormElements.php(101):
 Zend_Form_DisplayGroup-render() #5
 /usr/local/share/pear/Zend/Form.php(2626):
 Zend_Form_Decorator_FormElements-render('') #6
 /usr/local/share/pear/Zend/Form.php(2641): Zend_Form-render() #7
 /usr/local/www/
 svn.loopia.se/controlweb/umpirsky.test.af.loopia.se/application/views/scripts/userinfo/index.phtml(18)
 :
 Zend_Form-__toString() #8 /usr/local/share/pear/Zend/View.php(108):
 include('/usr/local/www/...') #9
 /usr/local/share/pear/Zend/View/Abstract.php(833):
 Zend_View-_run('/usr/local/www/...') #1 in
 /usr/local/share/pear/Zend/Form.php on line 2646

 My class:

 class My_Form_DisplayGroup extends Zend_Form_DisplayGroup {
public function loadDefaultDecorators() {
if ($this-loadDefaultDecoratorsIsDisabled()) {
return;
}

 $this-setDecorators(
array(
'ViewHelper',
array(array('td' = 'HtmlTag'), array('tag'
 = 'td', 'style' = 'width:
 360px;')),
array('Label', array('tag' = 'td',
 'requiredSuffix' = ' *')),
array(array('tr' = 'HtmlTag'), array('tag'
 = 'tr')),
array(array('tbody' = 'HtmlTag'),
 array('tag' = 'tbody')),
array(array('table' = 'HtmlTag'), array('tag'
 = 'table', 'class' =
 'tiny')),
array(array('separator' = 'HtmlTag'),
 array('tag' = 'div', 'class'
 = 'separator'))
)
);
}

 }

 Any idea?



 Tim Fletcher wrote:
 
  It took me long time to work out that in order to subclass
  Zend_Form_DisplayGroup, you must set the class appropriately. If you're
  creating your form by subclassing Zend_Form you should use :
 
  $this-setDefaultDisplayGroupClass('App_Form_DisplayGroup');
 

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




Re: [fw-general] Zend Form: Trying to add a Label Decorator to a DisplayGroup

2009-07-27 Thread Tim Fletcher

It took me long time to work out that in order to subclass
Zend_Form_DisplayGroup, you must set the class appropriately. If you're
creating your form by subclassing Zend_Form you should use : 

$this-setDefaultDisplayGroupClass('App_Form_DisplayGroup');
-- 
View this message in context: 
http://www.nabble.com/Zend-Form%3A-Trying-to-add-a-Label-Decorator-to-a-DisplayGroup-tp18097521p24682125.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend Form: Trying to add a Label Decorator to a DisplayGroup

2008-06-25 Thread jkendall

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
 
 labelBlah/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.



[fw-general] Zend Form: Trying to add a Label Decorator to a DisplayGroup

2008-06-24 Thread jkendall

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

labelBlah/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-tp18097521p18097521.html
Sent from the Zend Framework mailing list archive at Nabble.com.