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

amanda_benade
amanda_benade

Hi I have a plugin with models using $belongsTo relations. The relations managers display fine. Records are created and saved via the create or update relation buttons with no problem. However, when I try to update a record via the relation update button/form, it appears as if it is updating and saving, however, when I reopen the record, no changes were applied. I've logged the data passed to the model and the changes are not being passed to the models. So, the relation creates the record but will not update the same record.

In the models I have fields user_id, client_id, application_id with the relations defined as

public $belongsTo = [
    'user' => ['RainLab\User\Models\User'],
    'client' => ['DigiMed\RecordManager\Models\Client'],
    'application' => ['DigiMed\RecordManager\Models\Application'],
]; 

In the controller I have:

public $implement = [        
    'Backend\Behaviors\ListController',        
    'Backend\Behaviors\FormController',
    'Backend\Behaviors\RelationController'

];

public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public $relationConfig = 'config_relation.yaml';

In config_relation.yaml I have eg

application: label: 'Application' deferredBinding: true //I tried without deferredBinding as well view: form: $/digimed/recordmanager/models/application/fields.yaml toolbarButtons: update|delete manage: form: $/digimed/recordmanager/models/application/fields.yaml list: $/digimed/recordmanager/models/application/columns.yaml

Last updated

mjauvin
mjauvin

Are there any JavaScript errors on the console when you try to update records? Or in php/octobercms error logs?

amanda_benade
amanda_benade

Hi, no javascript errors and no PHP errors. For all intents & purposes updating is "successful", but it is passing & saving the original values instead of the updated values to the models.

mjauvin
mjauvin

I'd have to see more of your Mode/Controller classes to be able to help

mjauvin
mjauvin

Also, your config_relation.yaml should have:

view:
   list: ... path to columns.yaml

Not:

view:
   form: ...
mjauvin
mjauvin

disregard my last comment, this is fine with belongsTo relationships.

amanda_benade
amanda_benade

Thank you for assisting mjauvin. This is now an open issue on GitHub: https://github.com/octobercms/october/issues/5243

zs60815
zs60815

I'm still having this issue, with the lastest build. Am I missing something in config relation?

menuitem:
label: Menu Item
view:
    form: $/myplugins/menu/models/menuitem/fields.yaml
    toolbarButtons: create|update|link|unlink
manage:
    form: $/myplugins/menu/models/menuitem/fields.yaml
    list: $/myplugins/menu/models/menuitem/columns.yaml
mjauvin
mjauvin

@zs60815 you need to use branch 1.1.x (using composer) to get this fix.

ref. https://github.com/octobercms/october/commit/5a843bc90986a29ec0375697490af9864ecbd188

zs60815
zs60815

mjauvin said:

@zs60815 you need to use branch 1.1.x (using composer) to get this fix.

ref. https://github.com/octobercms/october/commit/5a843bc90986a29ec0375697490af9864ecbd188

You mean to change:

"extra": {
    "branch-alias": {
        "dev-master": "1.0-dev"
    }
},

To 1.1.x and run composer update?

mjauvin
zs60815
zs60815

mjauvin said:

No, use the composer file from the October git repo:

https://github.com/octobercms/october/blob/develop/composer.json

Thank you.

1-12 of 12

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