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

yfktn
yfktn

I want to use "many to many" relationship behavior, using add and remove toolbars buttons based on the doc in here. But, when I add or update pivot value with this, field that depend on it, does not updated because filterFields() function doesn't called.

When I check the code at \modules\backend\behaviors\relationcontroller\partials_pivot_form.htm, I found if Form::ajax does not fire $.oc.relationBehavior.changed.

Is this intended for it?

When I change the code and add "data-request-success" property of Form::ajax with $.oc.relationBehavior.changed, it works as I needed.

Here what I did with \modules\backend\behaviors\relationcontroller\partials_pivot_form.htm:

<?php if ($relationManageId): ?>

    <?= Form::ajax('onRelationManagePivotUpdate', [
        'data' => ['_relation_field' => $relationField, 'manage_id' => $relationManageId],
        'data-request-success' => "$.oc.relationBehavior.changed('" . e($this->vars['relationField']) . "', 'updated')",
        'data-popup-load-indicator' => true
    ]) ?>

   ...OTHER SOURCE...
    <?= Form::close() ?>

<?php else: ?>

    <?= Form::ajax('onRelationManagePivotCreate', [
        'data' => ['_relation_field' => $relationField, 'foreign_id' => $foreignId],
        'data-request-success' => "$.oc.relationBehavior.changed('" . e($this->vars['relationField']) . "', 'created')",
        'data-popup-load-indicator' => true
    ]) ?>

   ...OTHER SOURCE...

    <?= Form::close() ?>

<?php endif ?>

Sorry for my bad english ...

Last updated

1-1 of 1

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