pkp-lib
pkp-lib copied to clipboard
Can't use multilingual values in theme options
Describe the bug
Theme options can not use multilingual fields ('isMultilingual' => true). The field values are not properly converted to the correct type when saving to the database, and so the form fields don't work on subsequent attempts to save.
This is especially tricky with multilingual FieldOptions, which do not have any way to specify the type of each item.
It may be easier to support multilingual text fields only and to document this restriction in the theming guide.
To Reproduce Add the following example theme option to the default theme:
$this->addOption('test', 'FieldOptions', [
'label' => 'Test',
'description' => 'description',
'isMultilingual' => true,
'options' => [
'en_US' => [
[
'value' => '1',
'label' => 'test1',
],
[
'value' => '2',
'label' => 'test2',
],
],
'fr_CA' => [
[
'value' => '1',
'label' => 'test1fr',
],
[
'value' => '2',
'label' => 'test2fr',
],
],
],
'default' => [],
]);
Then try to test saving and reloading the page and changing values. Any values for languages that are not supported are stored as strings instead of arrays.
What application are you using? 3.3 (pre-release)
I've created a PR to fix the multilingual issue, but the problem with the FieldOptions under a multilingual setup is another issue, perhaps I'll tackle it, it will probably need some fixes at the ui-library.
Hey @jonasraoni, I've reviewed the PR and it looks good to me. 👍
Thanks!