Difference between #1 and #2 of
Custom Autocomplete Display and Value Submission

Revision #2 has been created by Maurizio Domba Cerin on Jul 15, 2011, 9:13:59 AM with the memo:

typo fix
« previous (#1) next (#3) »

Changes

Title unchanged

Custom Autocomplete Display and Value Submission

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

tutorial, autocomplete, jui

Content changed

[...]
2. Once user selects an item in the dropdown list and fill a hidden box with the id of the selected item for submission

##Making the right choice
To setup the autocomplete was a very straight forward operation, but I couldn't figure out how to get values from a custom JSON response and then fill the correspondent hidden fields.

CAutoComplete does ha
sve a way to do it, but I wanted to use CJuiAutoComplete to get all the cool features of its JQuery UiI and by looking at his code there was no method chain, something that is required to work with custom JSON responses as we need to override some methods.

##My Solution
[...]
Now that we have our beautiful widget that handles method chain in our Autocomplete, let's assume a couple of things:

* We saved our class
onto a folder in our application -folder - ie protected/extensions * We have a hidden INPUT HTML element with model's attribute_id * We have created an action on our testController named autocomplete that returns a JSON object onf the following format: ```php // This function will echo a JSON object // onf this format:
// [{id:id, name: 'name'}]
public function actionAutocomplete(){
$res = array();
$term = Yii::app()->getRequest()->getParam('term', false);
if ($term)
[...]
12 0
18 followers
Viewed: 60 903 times
Version: 1.1
Category: How-tos
Written by: Antonio Ramirez
Last updated by: SebK
Created on: Jul 14, 2011
Last updated: 11 years ago
Update Article

Revisions

View all history