Commit cd1152ac by Ivan Kolmycheck

GridView/DataColumn - moved error list display into GridView

parent 031fddd4
......@@ -15,6 +15,8 @@ use yii\helpers\Url;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\widgets\BaseListView;
use yii\helpers\ArrayHelper;
use yii\base\Model;
/**
* The GridView widget is used to display data in a grid.
......@@ -174,6 +176,17 @@ class GridView extends BaseListView
*/
public $filterRowOptions = ['class' => 'filters'];
/**
* @var string the layout that determines how different sections of the list view should be organized.
* The following tokens will be replaced with the corresponding section contents:
*
* - `{summary}`: the summary section. See [[renderSummary()]].
* - `{error}`: the filter model errors. See [[renderErrors()]].
* - `{items}`: the list items. See [[renderItems()]].
* - `{sorter}`: the sorter. See [[renderSorter()]].
* - `{pager}`: the pager. See [[renderPager()]].
*/
public $layout = "{summary}\n{errors}\n{items}\n{pager}";
/**
* Initializes the grid view.
......@@ -228,7 +241,17 @@ class GridView extends BaseListView
return Html::tag('div', Html::ul($errorsList, ['class' => 'help-block']), ['class' => 'has-error']);
}
return parent::renderErrors();
return '';
}
public function renderSection($name)
{
switch ($name) {
case "{errors}":
return $this->renderErrors();
default:
return parent::renderSection($name);
}
}
/**
......
......@@ -78,12 +78,11 @@ abstract class BaseListView extends Widget
* The following tokens will be replaced with the corresponding section contents:
*
* - `{summary}`: the summary section. See [[renderSummary()]].
* - `{errors}`: the errors section. See [[renderErrors()]].
* - `{items}`: the list items. See [[renderItems()]].
* - `{sorter}`: the sorter. See [[renderSorter()]].
* - `{pager}`: the pager. See [[renderPager()]].
*/
public $layout = "{summary}\n{errors}\n{items}\n{pager}";
public $layout = "{summary}\n{items}\n{pager}";
/**
* Renders the data models.
......@@ -92,15 +91,6 @@ abstract class BaseListView extends Widget
abstract public function renderItems();
/**
* Renders the list of errors, if there are any
* @return string the rendering result
*/
public function renderErrors()
{
return '';
}
/**
* Initializes the view.
*/
public function init()
......@@ -141,8 +131,6 @@ abstract class BaseListView extends Widget
public function renderSection($name)
{
switch ($name) {
case '{errors}':
return $this->renderErrors();
case '{summary}':
return $this->renderSummary();
case '{items}':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment