View Single Post
  #1 (permalink)  
Old 04-12-2008, 07:47 AM
xavisd xavisd is offline
Junior Member
 
Join Date: Mar 2008
Posts: 8
Question Custom decorator problem

I'm trying to understand how Zend_Form works. I've coded a Cms_Decorator_Label that extends Zend_Form_Decorator_Abstract (it writes a ':' after label text) but I cannot make it work correctly at a custo UserForm (extends Zend_Form)

try 1)
Code:
$this -> addPrefixPath('Cms_Decorator', 'Cms/Decorator/','decorator');
don't works

try 2)
Code:
$this -> addElementPrefixPath('Cms_Decorator', 'Cms/Decorator/','decorator');
don't works

try 3)
Code:
    $name = new Zend_Form_Element_Text('name');    
    $name -> addPrefixPath('Cms_Decorator', 'Cms/Decorator/','decorator');
don't works

try 4)
Code:
 $form = new UserForm(array('disableLoadDefaultDecorators' => true));
don't works

try 5)
Code:
$name = new Zend_Form_Element_Text('name',array('disableLoadDefaultDecorators' => true));
Element dissapears... we have something

try 6)
Code:
    $name = new Zend_Form_Element_Text('name',array('disableLoadDefaultDecorators' => true));    
    $name -> addPrefixPath('Cms_Decorator', 'Cms/Decorator/','decorator');
still invisible

try 7)
Code:
    $name = new Zend_Form_Element_Text('name',array('disableLoadDefaultDecorators' => true));    
    $name -> addPrefixPath('Cms_Decorator', 'Cms/Decorator/','decorator');
    $name -> addDecorator('Label');
ey!! A label with ':' !!! but it loses <dt> tag =/

try 8)
Code:
    $name = new Zend_Form_Element_Text('name',array('disableLoadDefaultDecorators' => true));    
    $name -> addPrefixPath('Cms_Decorator', 'Cms/Decorator/','decorator');
    $name -> addDecorator('Label',array('tag' => 'dt'));
not <dt> tag...

try 9)
search at zfforums -> nothing found -> write a post... =/

I've also tryed to don't disable default decoratos and add decorator class to element with:
Code:
$name -> addDecorator(new Cms_Decorator_Label(),array('tag' => 'dt'));
but then it write two labels (default and custom)

is there an easy way to do this?? i just want to create a custom decorator... =/
Reply With Quote