Yii Framework Forum: how to show multiple values in gridview with hanMany relation - Yii Framework Forum

Jump to content

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

how to show multiple values in gridview with hanMany relation Rate Topic: -----

#1 User is offline   Amjad Khan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 23-November 11

Posted 12 November 2014 - 11:26 AM

class Book extends ActiveRecord
{
    ....

    public static function tableName()
    {
        return 'books';
    }

    public function getAuthor()
    {
        return $this->hasOne(Author::className(), ['id' => 'author_id']);
    }

And Author
class Author extends ActiveRecord
{

    public static function tableName()
    {
        return 'authors';
    }

    public function getBooks()
    {
        return $this->hasMany(Book::className(), ['author_id' => 'id']);
    }



i just want to get author name with books how to do that in girdview in Yii2. I want multiple comma separated books names in a single column just like following
Author               Books
Alex                  C++ Programming,Yii Book,Java Cookbook


What should i do? please help(In Yii 2.0 GridView)
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