pkp-lib icon indicating copy to clipboard operation
pkp-lib copied to clipboard

Can't use multilingual values in theme options

Open NateWr opened this issue 5 years ago • 1 comments

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)

NateWr avatar Aug 18 '20 10:08 NateWr

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.

jonasraoni avatar Mar 29 '24 15:03 jonasraoni

Hey @jonasraoni, I've reviewed the PR and it looks good to me. 👍

ewhanson avatar Apr 26 '24 16:04 ewhanson

Thanks!

jonasraoni avatar Apr 26 '24 18:04 jonasraoni