Using Yii PHP framework. When you ask a question on stackoverflow, as you type the title a list appears called “Questions that may already have your answer”. I want to create similar type of field so that when users enter the name of a business I can display similar business names already in my system. It doesn’t necessarily need to be as sophisticated as stackoverflow’s model. A simple alphabetical search should be fine.
Keep in mind unlike a normal autocomplete, this “autocomplete” won’t actually fill in the field in question but rather serves as an informational tool to inform the user of data that potentially already exists.
I’m thinking Yii CJuiAutoComplete widget is the right tool for the job but how do I dissociate the autocomplete from the input field?
CJuiAutoComplete is definitely the right tool, and to disable the auto filling when selecting the suggested values, you will have to alter jQueryUI autocomplete’s behavior for its
selectevent, and also for itsfocusevent.The
selectevent is triggered when a suggestion item is clicked, andfocusevent is triggered when a suggestion item is navigated to by keystroke (up, down arrow keys).So to change the default behavior, which is updating the text field, you can cancel those events by returning false from their callbacks: