How to assign values to multilingual field in a modal

Hi everyone

I’m using a custom plugin for custom metadata field. The plugin works fine but when I try to edit the field in metadata modal the field of the language other than the selected language is empty. When I checked the code I think I figured out the problem but could not solve it.

The code that corresponds to displaying values in the metadata modal is:


The first line gets the value for the currently selected language and the second line assign it to the field “additional”. I can define a function that returns the value of the second language, but I don’t know how to assign it to the same field (but for the second language of the field).

Can anyone help me with this?

I couldn’t find a class MetadataFieldDAO or a method getAdditionalFieldValue() in OJS 3.1.2. Can you share more about the code you are trying, and the specific software and version you are using?

It’s a custom plugin. Class MetadataFieldDAO extends DAO class and has only one function namely getAdditionalFieldValue().
My question was how to update a multilingual field in a modal using $templateMgr->assign() function. I just found the answer after some search and experimenting. I will post the result in the next reply.

So, a multilingual field can be updated by simply passing an associative array to the function $templateMgr->assign().

The array takes the form $array[$locale]=$value_for_that_locale. For example:

$additional[‘en_US’]=“additional metadata”;
$additional[‘ar_IQ’]=“بيانات وصفية اضافية”;