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 unknown property: common\models\db\Category::depth #2

Open
russeljo opened this issue Oct 18, 2021 · 0 comments
Open

Getting unknown property: common\models\db\Category::depth #2

russeljo opened this issue Oct 18, 2021 · 0 comments

Comments

@russeljo
Copy link

Extension ask for depth property, but no words in readme about it
vendor\koperdog\yii2-treeview\base\TreeHelper.php at line 66– yii\db\BaseActiveRecord::__get()

for ($depth = $models[0]->depth; $n->depth > $depth; $depth++) {
       $node = &$node[count($node) - 1]->children;
}

in view i use

<?= TreeView::widget([
    'emptyText' => 'Nothing found',
    'layout' => "{items}\n{pager}",
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'tableOptions' => ['class' => 'table table-bordered table-hover dataTable'],
    'columns'      => [
        Category::ATTR_NAME,
        Category::ATTR_SLUG,
        [
            'label' => 'Parent category',
            'attribute' => Category::ATTR_PARENT_ID,
            'value' => 'parent.name'
        ],
        [
            'class' => 'yii\grid\ActionColumn',
            'template' => '{update} {delete}',
            'buttons' => [
                'update' => function ($url) {
                    return Html::a(
                        '<i class="fa fa-pencil" aria-hidden="true"></i>',
                        $url,
                        [
                            'title' => 'edit',
                            'class' => 'btn btn-primary'
                        ]
                    );
                },
                'delete' => function ($url) {
                    return Html::a(
                        '<i class="fa fa-trash" aria-hidden="true"></i>',
                        $url,
                        [
                            'title' => 'delete',
                            'class' => 'btn btn-danger',
                            'data-confirm' => 'confirm action',
                            'data-method' => 'POST',
                        ]
                    );
                },
            ],
        ],
    ]
]) ?>

Explain, please, data structure. How it idetify parents and childrens?

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