Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting All Tags for each model in CGridView #25

Open
larry-tx opened this issue Mar 1, 2014 · 0 comments
Open

Getting All Tags for each model in CGridView #25

larry-tx opened this issue Mar 1, 2014 · 0 comments

Comments

@larry-tx
Copy link

larry-tx commented Mar 1, 2014

I would like to have a CGridView column that displays all tags for each model listed in the index (list) and admin views. I've tried some thing like this in CGridView:

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'              => 'disks-grid',
    'dataProvider'    => $model->search(),
    'filter'          => $model,
    'columns'         => array(
      // additional column definitions
        array(
            'name'   => 'tags_with_model',
            'header' => 'Tags',
            'type'   => 'raw',
            'filter' => FALSE,
            'value'  => $model->tags_with_model->toString(),
        ),
        // ,,,

Unfortunately, that produces nothing. No errors, just a totally blank column. (Interestingly, I was able to use tags_with_model->toString(); ?> to display the tags in view.php, and it worked quite nicely.) Apparently, something happens in CGridView to prevent toString() from working.

By the way, my behavior in the model looks like:

public function behaviors() {
            return array(
                'tags_with_model' => array(
                    'class'                   => 'ext.yiiext.behaviors.model.taggable.ETaggableBehavior',
                    'tagTable'                => 'tag',
                    'tagBindingTable'         => 'disks_tag',
                    'modelTableFk'            => 'disksId',
                    'tagTablePk'              => 'id',
                    'tagTableCount'           => 'frequency',
                    'tagBindingTableTagId'    => 'tagId',
                    'createTagsAutomatically' => TRUE,
                ),
            );
        }

Can anyone tell me how to get a column in CGridView that displays the tags for each model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant