The all common CGridview relation/filter topic once again. How do you define a filter for translated values?
Scenario: Gridview where the user can search through several fields in his/her own language. Values in the DB are in English. Translation provided through Yii messages files.
function t in module MYMODULE delivers a translation for the data extracted (TEXTVALUE) from the database.
So in case if ‘TEXTVALUE’ would be ‘fruits’, it would display a translated value for ‘fruits’ in the gridview if the view language of the user is, say language NL.
‘columns’ => array(
array( 'name'=>'TEXTVALUE', 'type'=>'raw', 'value'=>'Yii::app()->getModule('MYMODULE')->t($data->TEXTVALUE)', ),
How can I make the filter/model/gridview code to use the translated input in the filter, ‘untranslated’ it to search the db, and filter the gridview accordingly (all without the use of the dropdown filter function).
So short example:
Gridview with 15 rows show, 1 column. Column contains a translated version of the contents of the DB (in this example. Source language is UK, target language is NL). User sees the values in the gridview in NL (translated), user wants to filter the contents by putting in a Dutch (NL) searchword in the filter.
How do I code compare or ‘search’ function of the model?
The example below works fine with English words, but not Dutch search words (obviously).
$criteria->compare(‘TEXTVALUE’, $this->TEXTVALUE, true);
How can I call the untranslate function on the filter so that it searches correctly in the db?