Hello Mathew,
I tried this, but wont work for me.
$form->addDisplayGroupPrefixPath('forms_Decorator', 'forms/Decorator');
.....
 $form->addDisplayGroup(array('username', 'password'), 'login', array(
        'legend'     => 'Please Login:',
        'decorators' => array(
            'FormElements',
            array('DivWrapper', array(
                'labelFor'   => 'login',
                'labelClass' => 'required left optional',
            ))
        ), 
......
and i have application/forms/Decorator/ with DivWrapper.php in it.
in bootstrap:
$base  = realpath(dirname(__FILE__) . '/../');
$paths = array(
    '.', 
    $base . '/library',
    $base . '/application',
    $base . '/application/forms',
    $base . '/application/models',
);
ini_set('include_path', implode(PATH_SEPARATOR, $paths));

Error i am getting:
exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name
DivWrapper was not found in the registry.' in....

Any suggestion?
Thanks
Vladimir

Matthew Weier O'Phinney-3 wrote:
> 
> What did you try? :)
> 
> Here's what I'd try: you'll need to create a custom decorator for the
> display group, which I'll detail below, and then the following
> element/group definitions.
> 
>     $form->addDisplayGroupPrefixPath('My_Form_Decorator',
> 'My/Form/Decorator');
>     $form->addElement('text', 'txtZipcode', array(
>         'size'       => 10,
>         'maxlength'  => 10,
>         'class'      => 'true',
>         'required'   => 'true',
>         'decorators' => array('ViewHelper'),
>     ));
>     $form->addElement('text', 'txtCity', array(
>         'size'       => 30,
>         'maxlength'  => 20,
>         'class'      => 'true',
>         'required'   => 'true',
>         'decorators' => array('ViewHelper'),
>     ));
>     $form->addDisplayGroup(array('txtZipcode', 'txtCity'), 'zipCity',
> array(
>         'legend'     => 'Zipcode/City',
>         'decorators' => array(
>             'FormElements',
>             array('DivWrapper', array(
>                 'labelFor'   => 'txtZipcode', 
>                 'labelClass' => 'required left optional',
>             ))
>         ),
>     ));
> 
> The DivWrapper decorator would look like this:
> 
>     My_Form_Decorator_DivWrapper extends Zend_Form_Decorator_Abstract()
>     {
>         public function render($content)
>         {
>             $group = $this->getElement();
>             if (null === $group) {
>                 return $content;
>             }
> 
>             $labelFor   = $this->getOption('labelFor');
>             $labelClass = $this->getOption('labelClass');
>             $label      = $group->getLegend();
> 
>             $html =<<<EOH
> <div class="row">
>     <label for="$labelFor" class="$labelClass">$label</label>
>     <div class="element">
>         $content
>     </div>
> </div>
> EOH;
>             return $html;
>         }
>     }
> 
> Put the above in My/Form/Decorator/DivWrapper.php on your include path,
> and you should be set.
> 
>> I think this is a common problem. So hopefully some can give me a hint
>> how my decorator needs to look like...
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect       | [EMAIL PROTECTED]
> Zend Framework           | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend-Form-Grouping-Elements-tp18890779p19439080.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to