Yii Framework Forum: Property "cactivedataprovider.0" Is Not Defined. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Property "cactivedataprovider.0" Is Not Defined. Rate Topic: -----

#1 User is offline   danray0424 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-November 12

Posted 15 November 2013 - 10:43 AM

I'm using a pair of date fields to filter output into a report of users by signup date. The initial load of data comes up great, but I get the titular error when AJAX'ing up a list filtered with the date fields.

View:
<?php
// Date range search inputs
$model = new User("searchPaid");
$attribute = 'premium_date';

echo CHtml::form('/admin/report/ajaxFilterPremiumUsersByJoinDate');

for ($i = 0; $i <= 1; $i++)
{
    echo ($i == 0 ? Yii::t('main', 'From:') : Yii::t('main', 'To:'));
    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
        'id'=>CHtml::activeId($model, $attribute.'_'.$i),
        'model'=>$model,
        'attribute'=>$attribute."[$i]",
        'options' => array(
            'dateFormat'=>'yy-mm-dd',
        ),
        'htmlOptions' => array(
            'style'=>'margin: 10px;',
        ),
    )); 
}
echo CHtml::ajaxSubmitButton('Filter', 
    '/admin/report/ajaxFilterPremiumUsersByJoinDate',
    array('update' => '#usersList'),
    array('class' => 'btn btn-primary')
);

echo CHtml::endForm();

?>

<div id="reportTitle">
    <h3>Report - Users by Signup Date</h3>
</div>

<div id='usersList'>
    <?php
    $this->widget('zii.widgets.grid.CGridView', array(
    	'id'=>'user-grid',
    	'dataProvider'=>$provider,
        //'filter'=>$model,
    	'columns'=>array(
            'id',
            'email',
            'firstname',
            'lastname',
            'join_date',
            'active:boolean',
            'premium_member:boolean',
            'premium_date'
        ),
        'enableSorting' => false,
    ));
    ?>
</div>



In the controller, in actionAjaxFilterPremiumUsersByJoinDate(), I'm trying two different ways to get my date ranges in there, neither of which change the error I'm getting. I've left them both in, so you can see what I've tried.

Controller:


    public function actionPaidSignups()
    {
        $model = new CActiveDataProvider('User', array(
            'criteria'=>array(
            'condition'=>'premium_member=1',
            ))
        );
        $this->render('premiumSignups', array(
            'provider' => $model
        ));
    }

    public function actionAjaxFilterPremiumUsersByJoinDate()
    {
        $crit = new CDbCriteria();
        $crit->addCondition("premium_member=1");
        if (isset($_POST['User'])){
            $pre = $_POST['User']['premium_date'][0];
            $post = $_POST['User']['premium_date'][1];
            $crit->addBetweenCondition("premium_date", $pre, $post);
        }
        $model = new CActiveDataProvider('User', array($crit));
        if(isset($_POST['User'])){
            $model->attributes=$_POST['User'];
        }
        $this->renderPartial('_ajaxPaidSignups', array(
            'model' => $model
        ));
    }



Partial _ajaxPaidSignups:

<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'user-grid',
	'dataProvider'=>$model,
    //'filter'=>$model,z
	'columns'=>array(
        'id',
        'email',
        'firstname',
        'lastname',
        'join_date',
        'active:boolean',
        'premium_member:boolean',
        'premium_date'
    ),
    'enableSorting' => false,
));
?>

0

#2 User is offline   Argent 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 23-February 13
  • Location:Hungary

Posted 15 November 2013 - 04:47 PM

Try this code:
$model = new CActiveDataProvider('User', array("criteria"=>$crit));

instead of

Quote

$model = new CActiveDataProvider('User', array($crit));

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users