This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Demetrius
Demetrius

I'm currently building a plugin which needs a simple category/sub-category implementation. I decided to use the SimpleTree trait, since the NestedTree is too complex for what I want to achieve. However, for some reason it doesn't seem to work.

When I use the "type: relation" in my forms.yaml file, it keeps telling me there is no definition for "parent" in the model, while I think I might assume this would be solved by the SimpleTree implementation. I tried to get around this by adding the "parent" definition as a $hasOne, $belongsTo etc. But to no avail.

Another problem caused by this is the user being able to select a category as its own parent... Which is totally wrong. I've been trying to get it fixed, but no luck so far. Hope someone can help me out.

Last updated

daftspunky
daftspunky

Post some sample code on the github issues list, so it can be replicated, and I will take a look.

Demetrius
Demetrius

Category model => http://www.codeshare.io/kS2bt

Category fields.yaml => http://www.codeshare.io/LwyAU

Here's the code. Apparently it works for the forum plugin when using nested trees... Would expect similar functionality with SimpleTree

Last updated

GuilhermeJZ
GuilhermeJZ

I am having the same problem. Solutions?

GuilhermeJZ
GuilhermeJZ

Worked for me, but I had to define the relations in the model:

public $hasMany = [
    'children' => ['\Celepar\Catalogo\Models\TipoServico']
];

public $belongsTo = [
    'parent' => ['\Celepar\Catalogo\Models\TipoServico']
];

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.