Bonjour,
J'essai d'implementer un autocomplete avec Zend Form. Et bien sur, encore un soucis de décorators. Pourtant, je fais bien ce que préconise la doc. Et j'ai cette erreur :
ZendX_JQuery_Form_Exception: Cannot render jQuery form element without at least one decorator implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface. Default decorator for this marker interface is the 'ZendX_JQuery_Form_Decorator_UiWidgetElement'. Hint: The ViewHelper decorator does not render jQuery elements correctly. in /usr/share/php/libzend-framework-php/1/extras/library/ZendX/JQuery/Form/Element/UiWidget.php on
Il faut donc mettre le decorateur UiWidgetElement et c'est ce que je fais pourtant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
class Frontoffice_Form_Find extends Zend_Form {
 
    public $elementDecorators = array(
        'ViewHelper',
        'Errors',
        array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
        array('Label', 
               array('tag' => 'td')),
        array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
    );
 
    public $defaultDecorators =array(
        'FormElements',
        array('HtmlTag',
               array('tag' => 'table','class' => 'zend_form responsive' )
        ),
        'Form'
     );
 
    public function loadDefaultDecorators()  {        
        $this->setDecorators($this->defaultDecorators);
        $this->setElementDecorators ($this->elementDecorators);
    }
 
    public function init() {
        $config = Zend_Registry::get('config');
 
        $action =  $this->getView()->url(array(), 'list_place');
 
        $this->setMethod('post')
        ->setAction("#")
        ->setAttrib('id','geocoding_form')
        ->setAttrib('class','forms');
 
        $address = new Zend_Form_Element_Text('ANN_ADRESSE_1');
        $address->setLabel('address')
        ->addFilter('StripTags')
		->addFilter('StringTrim')
		->setAttrib('maxlength','255')
		->setAttrib('title',Zend_Registry::get('Zend_Translate')->translate('tooltip choice address'))
		->addValidator('notEmpty')
		->getValidator('notEmpty')->setMessage('msg address');
		///////////////////////////////////////////
 
       // Add Autocomplete Element
       $city = new ZendX_JQuery_Form_Element_AutoComplete(
                "ac1", array('label' => 'Autocomplete:')
            );
        $city->setJQueryParams(array('source' => array('New York',
                                             'Berlin',
                                             'Bern',
                                             'Boston')));
        $city->setDecorators(
                    array(
                        'UiWidgetElement',
                        array('ViewScript', array('class' => 'RegElement'))
                    )
            );
 
        ///////////////////////////////////////////
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setValue('Submit')
        ->setLabel('Valider')
        ->setAttrib('class','button')
        ->setDecorators($this->submitDecorators)
        ;          
 
        $this->addElements(array($address,$city,$submit));
 
   }
 
}