I’m trying to create an external field to filter a GridView.
I created a field outside of my Grid:
<input type="text" class="form-control" name="ModelSearch[dummy]" value>
Specified ‘filterSelector’ option for the Grid:
echo GridView::widget([
...
'filterSelector' => "input[name='ModelSearch[dummy]']",
...
]);
Added a special attribute in ModelSearch (I’d need to transform the value in the real case):
public function attributes() {
return array_merge(parent::attributes(), ['dummy']);
}
Now, everything works fine (the Search Model receives the value from the external input), but when the page reloads - the external input field is empty and I want it to be populated with the value I previously inserted (which it was filtered on), like it is done with standard filter fields. It is being passed back (there is …ModelSearch%5Bdummy%5D=123… in the url when Grid is reloaded) but the field is always empty.
Please suggest where do I need to setup this.
UPDATE:
Ended up simply checking the $_GET array and if the value is there, populating the field.