未定义的变量:类yii2
问题描述:
When I insert this code in gridview, there is error Undefined variable: class
'value' => 'order_customFields_delivery_method',
'contentOptions' => function ($data)
{
if ($data['order_customFields_delivery_method'] == 'Euro')
{
$class = 'style';
}
return [$class => 'font-weight: bold;'];}
],
In what can be a problem?
答
When condition inside if
is not met $class
is not set but you try to use it anyway.