PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 30, 2021

[FIXED] Yii: CGridView fails to render because missing ID field

 December 30, 2021     yii     No comments   

Issue

In my model, the id field is missing and I need to render a gridview which failed to render:

CException

Property "DocumentRequests.id" undefined.

I have a field document_request_id instead of id

Does the GridView work with the id field and if so, how can I override it?


Solution

I found the answer, how to override the id field if missing:

$data_provider_grid = new CArrayDataProvider($data_provider_grid, array(
            'id' => 'user',
            'keyField' => 'document_request_id',
            'pagination' => array(
                'pageSize' => $pageSize,
            ),
        ));


Answered By - Ionut Flavius Pogacian
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing