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

1-7 of 7