Cgridview Filter Autocomplete Issue

I have a CGridView with a phone related fields (phone numbers, imei, etc). When you start typing in the filter box for this column, you get a dropdown list of previous data you’ve typed in this field. This is not desirable behavior in this app, because a single user will be the main one using it, and she will be searching for all manner of records, not just a few… This feature, while helpful for many applications, would hinder in this case.

In the _form.php file, I’ve disabled autocomplete when entering new records by adding an htmlOption of ‘autocomplete’=>‘off’, but I can’t seem to find a way to disable this on the filter portion of a CGridview.

In my ‘columns’ definition, I’ve tried:

      array ('name' => 'imei',




      array ('name' => 'imei',



But neither works… In the case of the ‘htmlOptions’, it places the autocomplete on the cell for the rows of data. With ‘filterHtmlOptions’, it places is on the filter cell, not on the <input> tag itself.

How can I add ‘autocomplete’=>‘off’ to the input tag?

You could override the getFilterCellContent method or add script like

jQuery('tr.filters td > input[type=text]').attr('autocomplete', 'off');

Thank you!

I added your jQuery code to a registerScript, but it didn’t seem to work. Since I didn’t have input fields on the page that needed autocomplete, I tried disabling it for all inputs and that worked:

Yii::app()->clientScript->registerScript('disable_autocomplete', "

jQuery('input[type=text]').attr('autocomplete', 'off');