autocompletezend-framework2textfieldzend-formzend-form-element

Is there / What is a suggested way to create autocompleted form fields in ZF2?


Does the ZF2 Form (zendframework/zend-form) provide a mechanism to create text fields with autocompleted value list? Or is it just done by using the common Zend\Form\Element\Text, a Controller, that provides the data, and some JavaScript (not by ZF generated, but implemented in any proper way)?


Solution

  • Zend Form doesn't have such mechanism, so proper way is use AJAX request with JSON response. See Rob Allen's tutorial for this:

    Returning JSON from a ZF2 controller action