Skip to content

Loading…

CDataProvider bugfix #1547

Merged
merged 3 commits into from

3 participants

@Ryadnov

if create dataprovider with custom sorter (or paginator)

$dataProvider = new CActiveDataProvider('Model', array(
    'sort' => array(
        'class' => 'MySort',
    ),
));

we get error Property "CSort.class" is not defined.

issue: #1546

@creocoder

Good catch.

@samdark
Yii Software LLC member

Is this is fix for this release changes or it was the same in 1.1.12?

@samdark samdark was assigned
@creocoder

@samdark For this release.

@samdark samdark merged commit dcb7524 into yiisoft:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 8, 2012
  1. @Ryadnov

    CDataProvider fix - issue #1546

    Ryadnov committed
  2. @Ryadnov

    fix typo

    Ryadnov committed
  3. @Ryadnov
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 6 deletions.
  1. +3 −2 framework/web/CActiveDataProvider.php
  2. +18 −4 framework/web/CDataProvider.php
View
5 framework/web/CActiveDataProvider.php
@@ -106,11 +106,12 @@ public function setCriteria($value)
/**
* Returns the sorting object.
+ * @param string $className the sorting object class name. Parameter is available since version 1.1.13.
* @return CSort the sorting object. If this is false, it means the sorting is disabled.
*/
- public function getSort()
+ public function getSort($className='CSort')
{
- if(($sort=parent::getSort())!==false)
+ if(($sort=parent::getSort($className))!==false)
$sort->modelClass=$this->modelClass;
return $sort;
}
View
22 framework/web/CDataProvider.php
@@ -82,7 +82,7 @@ public function getPagination($className='CPagination')
* @param mixed $value the pagination to be used by this data provider. This could be a {@link CPagination} object
* or an array used to configure the pagination object. If this is false, it means the pagination should be disabled.
*
- * You can configre this property same way as a component:
+ * You can configure this property same way as a component:
* <pre>
* array(
* 'class' => 'MyPagination',
@@ -94,7 +94,14 @@ public function setPagination($value)
{
if(is_array($value))
{
- $pagination=isset($value['class']) ? $this->getPagination($value['class']) : $this->getPagination();
+ if(isset($value['class']))
+ {
+ $pagination=$this->getPagination($value['class']);
+ unset($value['class']);
+ }
+ else
+ $pagination=$this->getPagination();
+
foreach($value as $k=>$v)
$pagination->$k=$v;
}
@@ -123,7 +130,7 @@ public function getSort($className='CSort')
* @param mixed $value the sorting to be used by this data provider. This could be a {@link CSort} object
* or an array used to configure the sorting object. If this is false, it means the sorting should be disabled.
*
- * You can configre this property same way as a component:
+ * You can configure this property same way as a component:
* <pre>
* array(
* 'class' => 'MySort',
@@ -135,7 +142,14 @@ public function setSort($value)
{
if(is_array($value))
{
- $sort=isset($value['class']) ? $this->getSort($value['class']) : $this->getSort();
+ if(isset($value['class']))
+ {
+ $sort=$this->getSort($value['class']);
+ unset($value['class']);
+ }
+ else
+ $sort=$this->getSort();
+
foreach($value as $k=>$v)
$sort->$k=$v;
}
Something went wrong with that request. Please try again.