mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 22:09:48 +08:00
Refactored the code for #3154
This commit is contained in:
@@ -24,6 +24,7 @@ Yii Framework 2 Change Log
|
|||||||
- Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
|
- Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
|
||||||
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
|
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
|
||||||
- Enh #3132: `yii\rbac\PhpManager` now supports more compact data file format (qiangxue)
|
- Enh #3132: `yii\rbac\PhpManager` now supports more compact data file format (qiangxue)
|
||||||
|
- Enh #3154: Added validation error display for `GridView` filters (ivan-kolmychek)
|
||||||
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
|
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
|
||||||
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
|
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
|
||||||
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
|
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class GridView extends BaseListView
|
|||||||
* The following tokens will be replaced with the corresponding section contents:
|
* The following tokens will be replaced with the corresponding section contents:
|
||||||
*
|
*
|
||||||
* - `{summary}`: the summary section. See [[renderSummary()]].
|
* - `{summary}`: the summary section. See [[renderSummary()]].
|
||||||
* - `{error}`: the filter model errors. See [[renderErrors()]].
|
* - `{errors}`: the filter model errors. See [[renderErrors()]].
|
||||||
* - `{items}`: the list items. See [[renderItems()]].
|
* - `{items}`: the list items. See [[renderItems()]].
|
||||||
* - `{sorter}`: the sorter. See [[renderSorter()]].
|
* - `{sorter}`: the sorter. See [[renderSorter()]].
|
||||||
* - `{pager}`: the pager. See [[renderPager()]].
|
* - `{pager}`: the pager. See [[renderPager()]].
|
||||||
@@ -227,21 +227,16 @@ class GridView extends BaseListView
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* Renders validator errors of filter model.
|
||||||
|
* @return string the rendering result.
|
||||||
*/
|
*/
|
||||||
public function renderErrors()
|
public function renderErrors()
|
||||||
{
|
{
|
||||||
if ($this->filterModel instanceof Model && $this->filterModel->hasErrors())
|
if ($this->filterModel instanceof Model && $this->filterModel->hasErrors()) {
|
||||||
{
|
return Html::tag('div', Html::ul($this->filterModel->getFirstErrors(), ['class' => 'help-block']), ['class' => 'has-error']);
|
||||||
$errorsList = [];
|
} else {
|
||||||
foreach($this->filterModel->errors as $attribute => $errors)
|
return '';
|
||||||
{
|
|
||||||
$errorsList = ArrayHelper::merge($errorsList, $errors);
|
|
||||||
}
|
|
||||||
return Html::tag('div', Html::ul($errorsList, ['class' => 'help-block']), ['class' => 'has-error']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderSection($name)
|
public function renderSection($name)
|
||||||
@@ -351,7 +346,7 @@ class GridView extends BaseListView
|
|||||||
$content .= $this->renderFilters();
|
$content .= $this->renderFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "<thead>\n" . $content . "\n</thead>";
|
return "<thead>\n" . $content . "\n</thead>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -448,7 +443,7 @@ class GridView extends BaseListView
|
|||||||
} else {
|
} else {
|
||||||
$options = $this->rowOptions;
|
$options = $this->rowOptions;
|
||||||
}
|
}
|
||||||
$options['data-key'] = is_array($key) ? json_encode($key) : (string) $key;
|
$options['data-key'] = is_array($key) ? json_encode($key) : (string)$key;
|
||||||
|
|
||||||
return Html::tag('tr', implode('', $cells), $options);
|
return Html::tag('tr', implode('', $cells), $options);
|
||||||
}
|
}
|
||||||
@@ -466,7 +461,7 @@ class GridView extends BaseListView
|
|||||||
$column = $this->createDataColumn($column);
|
$column = $this->createDataColumn($column);
|
||||||
} else {
|
} else {
|
||||||
$column = Yii::createObject(array_merge([
|
$column = Yii::createObject(array_merge([
|
||||||
'class' => $this->dataColumnClass ?: DataColumn::className(),
|
'class' => $this->dataColumnClass ? : DataColumn::className(),
|
||||||
'grid' => $this,
|
'grid' => $this,
|
||||||
], $column));
|
], $column));
|
||||||
}
|
}
|
||||||
@@ -491,7 +486,7 @@ class GridView extends BaseListView
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Yii::createObject([
|
return Yii::createObject([
|
||||||
'class' => $this->dataColumnClass ?: DataColumn::className(),
|
'class' => $this->dataColumnClass ? : DataColumn::className(),
|
||||||
'grid' => $this,
|
'grid' => $this,
|
||||||
'attribute' => $matches[1],
|
'attribute' => $matches[1],
|
||||||
'format' => isset($matches[3]) ? $matches[3] : 'text',
|
'format' => isset($matches[3]) ? $matches[3] : 'text',
|
||||||
|
|||||||
Reference in New Issue
Block a user