Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 31-07-2009 23:21:06

Vincent
Administrateur
Date d'inscription: 19-09-2008
Messages: 510

[Zend_Form][1.5][EN] Les décorateurs avec Zend_Form

Publié le 05/05/2009

Zend_Form  has been lauded by many as a welcome addition to Zend Framework, and a flexible solution to the problem of forms. That said, one point of flexibility it offers has proved to be a pain point for many developers: decorators. This tutorial aims to shed some light on decorators, as well as provide strategies for creating your own decorators and combining them in creative ways to customize the output your forms generate.

Par Matthew Weier Ophinney

Lien: http://devzone.zend.com/article/3450


aka miboo

Hors ligne

 

#2 18-11-2009 12:50:28

Snoopy
Nouveau membre
Date d'inscription: 07-05-2009
Messages: 4

Re: [Zend_Form][1.5][EN] Les décorateurs avec Zend_Form

Hello,

am using a Zend_Form_Element_File in my form.

but when i passed a decorator i got an error " Exception caught by form: No file decorator found... unable to render file element Stack Trace: #0 /var/www/pg/ividence/library/Zend/Form/Decorator/FormElements.php(101): Zend"

$file->setLabel($this->view->translate('Image'))->setRequired(false)
             ->setAttrib('id', 'news-image')
             ->addValidator('FilesSize', false, 10000)
             ->addValidator('ImageSize', false, array('minwidth' => 30, 'maxwidth' => 90, 'minheight' => 30, 'maxheight' => 90))
             ->addValidator('Extension', false, 'jpg,png,gif');

$form->setElementDecorators(array(
                'ViewHelper',
                'Description',
                'Label',
                'Errors',
                new Zend_Form_Decorator_HtmlTag(
               array('tag' => 'li','class'=>'news'))
            ), array('image'));

is there a way to pass the file upload element within an li tag like that

    <li class="news">
     <label>Image</label>
     <input id="MAX_FILE_SIZE" type="hidden" value="2097152" name="MAX_FILE_SIZE"/>
     <input id="news-image" type="file" name="image"/>
   </li>

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages