Rohit,
There are three steps for creating a custom decorator. See where you are
going wrong:
Step 1: Create your decorator file
Step 2: Place your decorator file in the decorator path.
You can do this either by applying addPrefixPath() to each of your elements
or the addElementPrefixPath() method which will apply the decorator to all
form elements. However, addElementPrefixPath() method will work only when
you have created elements using the form object. If you are instantiating
your element directly, then use addPrefixPath() on each of your element. See
below code sample:
/**
* Text Element - FULL NAME
*/
$fullname = new Zend_Form_Element_Text('fullname');
$fullname->addPrefixPath('forms_Decorator',
'../application/forms/Decorator/', 'decorator');
$fullname->setLabel('Full Name')
->setDecorators(array('Composite'))
->setRequired(true);
Step 3: Set your custom decorator on the element
$fullname->setDecorators(array('Composite'));
Jerry
Rohit83 wrote:
>
> Hi
> I have written one class named Composite ,in which i have written the
> custom decorators,
> shall i instantiate this class like $decorator = new
> decorator_Composite();
> as we do for $decorator = new Zend_Form_Decorator_Label();
> and if i do this and apply decorators to some of the elements of the
> form,decorators wont apply
> to elements,
> Will anybody please help me out,
> Thanks in advance
> Regards
> Rohit
>
>
>
--
View this message in context:
http://www.nabble.com/Instantiating-custom-decorators-tp18029723p18055871.html
Sent from the Zend Framework mailing list archive at Nabble.com.