Error Relation behavior does not contain a definition for

Error Relation behavior does not contain a definition for
In clicke list relation

Version oc 3.7

Hi @Dheia,

Have you defined the relation correctly in your model?

Here’s the documentation on setting up the Relation Controller:

The error is in the RainLab.User Plugins Version 3
And User Plus+ plugin
Vdrsion 2

In Address Book
Relation name addresses

This error occurs in the relationship type has Many. I checked the code and saw the same error in more than one place, although I am sure the code is correct. I even have other add-ons that contain the same relationships and work on the oc-v2 version. When copying the same add-on to the oc-v3.7 version, the same error occurs. Please confirm the causes of this error in the Backend\Behaviors\RelationController class.

Note: This error occurred only when editing, that is, when clicking on the private record in the relationship to edit it.

You can watch the following video to make sure that the error is even in the Test Plugin


It seems that this error is due to the RelationController class.

You can verify yourself that the error is indeed present in oc-v3.7 and newer versions. Please solve this problem.

The error appears in all Plugins, even in the Test Plugin , RainLab.User Plugins Version 3
And User Plus+ plugin …

Octobercms release oc-v3.7.7 and newer versions

I found out that the problem is caused by one of the js files that is modifying the relationship class $.oc.relationBehavior

The code causing the problem is

if ($.oc.relationBehavior != null) {
        $.oc.relationBehavior.clickViewListRecord = function(recordId, relationId, sessionKey){
            let newPopup = $('<a />'),
                $container = $('#'+relationId),
                requestData = paramToObj2('data-request-data', $container.data('request-data'));

            let data = {
                'manage_id': recordId,
                '_session_key': sessionKey
            };
            let form = $(`#${relationId}`).parents('form').first();
            if (form.length) {
                form = form.serializeArray();
                for (let i = 0; i < form.length; i++) {
                    if (form[i].name.substr(0, 1) !== '_') {
                        data[form[i].name] = form[i].value;
                    }
                }
            }
            newPopup.popup({
                handler: 'onRelationClickViewList',
                size: 'huge',
                extraData: $.extend({}, requestData, data)
            })
        }
    }


The problem was solved as follows:


if ((! oc.useTurbo && ! oc.useTurbo()) && $.oc.relationBehavior != null) {
//.....
    }

I apologize to you and thank you.