Back to Extender Support

funteapot15611
funteapot15611

Hi, the model has the conditions or scope bug, please view http://octobercms.com/forum/post/modify-the-code-to-solved-using-conditions-scope-not-working-bug This is my fixed, but I think it is not good.

I think your plugin maybe can fix this bug, but it is used in controller, how to use in model? public $belongsTo = [ 'priority' => ['Leadrive\Pm\Models\ConfigStatus', 'conditions' => 'field_name = "wx_issue_priority"' //'scope' => 'isWxIssuePriority' ], ];

in the columns.yaml columns: priority_name: label: 'leadrive.pm::lang.wxissue.priority' relation: priority select: name sortable: true width: 100px

In the model, if the relation has conditions or scope, it will not work, such in the list, it will not working, because the 'priority' return more records. The table leadrive_pm_config_statuses maybe is: id field_name name 1 wx_issue_priority priority class 1 1 issue_priority priority class 1

Because the conditions did not work, so it will return 2 records(the correct answer is one record),

cydrick.nonog
cydrick.nonog

Hi,

The url that you have post is you have been changed one core file of cms. In that case that is not good idea.

In plugin extender, I extend the realtion controller fixed the bug in their, all you need to do is do the normal thing that you are doing in model.

About your problem in 2 records is returned make sure condition that you are creating will return 1. Or add limit

Thanks

funteapot15611
funteapot15611

cydrick.nonog said:

Hi,

The url that you have post is you have been changed one core file of cms. In that case that is not good idea.

In plugin extender, I extend the realtion controller fixed the bug in their, all you need to do is do the normal thing that you are doing in model.

About your problem in 2 records is returned make sure condition that you are creating will return 1. Or add limit

Thanks

Thanks your reply.

For the RelationBehavior Step 1: Instead of using "Backend.Behaviors.RelationController" to implement in Controller, use "Cyd293\Extenders\Behaviors\RelationController"

Step 2: add this "\Cyd293\Extenders\Traits\RelationTrait" trait in your controller

My controller did not have RelationController implement, it only have public $belongsTo in the model. And the $belongsTo has a conditions, but the OctoberCMS has a bug, so the conditions did not working.

public $belongsTo = [ 
    'priority' => ['Leadrive\Pm\Models\ConfigStatus',
        'conditions' => 'field_name = "wx_issue_priority"' 
        //'scope' => 'isWxIssuePriority' 
    ], 
];

So I want to know how to use your plugin in the model?

Last updated

cydrick.nonog
cydrick.nonog

Hi,

May Plugin is just extends the RelationController that the OctoberCMS has. So this is only extends the Controller,

May I know the whole code that you are trying to do, and how you want it to be display, so that i can check on it and update my plugin if ever

Thanks

funteapot15611
funteapot15611

cydrick.nonog said:

Hi,

May Plugin is just extends the RelationController that the OctoberCMS has. So this is only extends the Controller,

May I know the whole code that you are trying to do, and how you want it to be display, so that i can check on it and update my plugin if ever

Thanks

Hi, I create a demo to show this bug, please visit: https://github.com/Leadrive/Test

Thanks.

jeff29517
jeff29517

I am getting "Call to undefined method .... ::relationExtendQuery()" when I add to my model.

Trying to setup fix for relationships so i can use scope. Thoughts?

1-6 of 6