Custom $summary causes GridView to not render correctly

Hi,

When setting $summary to something, GridView does not generate the containing HTML tag defined in $summaryOptions. So in the following example:




 <?php 

	echo GridView::widget([

		'dataProvider' => $dataProvider,

		'summary'=>'Displaying <b>{begin}</b>-<b>{end}</b> of <b>{totalCount}</b>.',

		// ...

	]); 

?>



One would expect to have a HTML code of, for example,


<div class="summary">Displaying <b>1-20</b> of <b>24</b>.</div>

[size="2"] but instead it gives only [/size]


Displaying <b>1-20</b> of <b>24</b>.

thus[size="2"] omitting the <DIV> tag.[/size]

[size="2"]Looking at the code of the [/size]yii\widgets\BaseListView, the function renderSummary() starting at line 180 does not use


Html::tag($tag, ..., $summaryOptions);

when $summary is not NULL.

So I think the last return section of the code (starting at line 222) should be:


return Html::tag($tag,Yii::$app->getI18n()->format(/*...*/), $summaryOptions);

instead of only


return Yii::$app->getI18n()->format(/*...*/);

Is this intended (can someone explain why?) or is it a bug?

Thanks.

Rabb

I would like to see the entire snippet for GridView::widget() first, are you setting the summaryOptions as well or just the summary?

GridView extends BaseListView and renderSummary is defined in the latter. It doesn’t make a difference whether summaryOptions is set or left to default. If you look at those lines starting from 222, it leaves out the use of summaryOptions.

Btw, it works as expected if I do as I suggested in my original post; that is changing it to:


return Html::tag($tag,Yii::$app->getI18n()->format(/*...*/), $summaryOptions);