cpucpu
(Soyhobo)
June 4, 2016, 9:32pm
1
\yii\grid\gridview creates an input field for filtering if \yi\grid\Column::filter is not set. If I were to manually create the input field with said property, what would be the required code. As what I’m trying
'filter'=> '<input type="text" name="OrderSearch[number]" class="form-control">',
isn’t working properly. Since is not showing validation errors (.error-class is not being added on validation error, etc). Does filter though.
patrickm
(Yiiframework)
June 6, 2016, 12:04pm
2
Your OrderSearch model has validation rules defined?
You’d have to trigger its “validate” method and then maybe an active input field as filter would show validation errors: http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#activeInput()-detail
cpucpu
(Soyhobo)
June 6, 2016, 10:45pm
3
Hi, no luck.
[
'attribute' => 'number',
//'filter'=> '<input type="text" name="OrderSearch[number]" class="form-control">',
'filter' => html::activeInput('text', $searchModel, 'number'),
'format' => 'raw',
'value' => function($model) {
//return sprintf('%08d', $model->number);
return Html::a(sprintf('%08d', $model->number), ['customer/orders', 'id'=>$model->customer->id, 'highlight'=>$model->id]);
}],
It IS validating, It IS filtering, but IS NOT showing model errors when applicable.
patrickm
(Yiiframework)
June 7, 2016, 9:32pm
4
cpucpu
(Soyhobo)
June 8, 2016, 8:20pm
5
Yes It does. Accorging to Xdebug it is at
$searchModel->*yii\base\Model*_errors['number']
I don’t know what the value is since It “can not get property” but I guess that’s not relevant.
cpucpu
(Soyhobo)
June 9, 2016, 5:42pm
6
cpucpu:
Yes It does. Accorging to Xdebug it is at
$searchModel->*yii\base\Model*_errors['number']
I don’t know what the value is since It “can not get property” but I guess that’s not relevant.
Does anyone know whether this is the expected behaviour?
patrickm
(Yiiframework)
June 9, 2016, 6:03pm
7
Does it work with the standard input field, if you do not set "filter"?
If so, have a look at the html and compare it to what’s generated in your case - might give you an idea.