The problem is: I cannot select one of the boxes individually, it always behaves like ‘select all’.
It works if the name of the Field is ‘sidebar’ (not ‘ddc’), but that obviously isn’t a solution.
How can I get this working?
Another Question is: what should be the type of the corresponding schema?
Hmm, the problem you describe (behaviour like ‘select all’) suggests that the variable being passed in as the value is not an array. Using the numeric indexes like you do shouldn’t be causing any issue. But I’m not sure how this gets encoded to JSON and then decoded into a JavaScript variable, so try removing them. (You can also remove the 'type' => 'checkbox' since this is the default.)
The Problem now is I get the error: “The form was not saved because 1 error(s) were encountered. Please correct these errors and try again.” and in my logfile:
[18-May-2020 11:36:55 UTC] PHP Warning: Invalid argument supplied for foreach() in /srv/www/ojs02/htdocs/lib/pkp/classes/handler/APIHandler.inc.php on line 284
[18-May-2020 11:36:55 UTC] PHP Notice: Undefined index: type in /srv/www/ojs02/htdocs/lib/pkp/classes/handler/APIHandler.inc.php on line 343
[18-May-2020 11:36:55 UTC] PHP Notice: Trying to get property ‘type’ of non-object in /srv/www/ojs02/htdocs/lib/pkp/classes/handler/APIHandler.inc.php on line 343
[18-May-2020 11:36:55 UTC] PHP Notice: Undefined index: validation in /srv/www/ojs02/htdocs/lib/pkp/classes/handler/APIHandler.inc.php on line 343
[18-May-2020 11:36:55 UTC] PHP Notice: Trying to get property ‘type’ of non-object in /srv/www/ojs02/htdocs/lib/pkp/classes/handler/APIHandler.inc.php on line 343
[18-May-2020 11:36:55 UTC] PHP Notice: Trying to get property ‘type’ of non-object in /srv/www/ojs02/htdocs/lib/pkp/classes/services/PKPSchemaService.inc.php on line 331
[18-May-2020 11:36:55 UTC] PHP Notice: Trying to get property ‘type’ of non-object in /srv/www/ojs02/htdocs/lib/pkp/classes/services/PKPSchemaService.inc.php on line 338
thanks again for your help.
As I’ve written, FieldOptions() does work correctly when I write the schema directly into context.json.
Now in our real journals I want to add some custom fields to the metadata page under the keywords
(don’t know if this is a problem since the keywords are multilingual).
I can get it right with FieldSelect(), no problem. But when I use FieldOptions() as above, even with the schema in the json-file (this time publication.js),
the “select all”-behaviour occurs. Regardless if the “value” is an array or not. When there is no new schema in publication.json, this behaviour goes away. I no case can I save the form.
Another problem is how to get the submissionId/publication and so on. I guess the “form”-object is different in this case.
Sorry for asking so many questions…
I have another new updated and untouched OJS (no own themes or plugins), it shows the same behaviour. When I use the above code it works correctly as in your video. But that is the same with my other OJS, what I tried to explain before. The problem only starts when I try to implement the schema.
I will try and get another OJS from github.
Can you share the full PHP code where you add the property to the schema from your plugin? You shared a JSON snippet but I’d like to see where your plugin extends the schema.
It suddenly worked using json_decode, I could save the form a few times. Before that I toggled the ‘type’ fom ‘array’ to ‘object’ and back again.
After that I used the lower code (without json_decode), and then it did again not work.
I know it sounds crazy, but it felt like this is unpredictable.
I really need your full code, not just snippets. If you don’t want to share your code in a public forum you can send it by PM, but otherwise I can’t reproduce the problem locally and so I won’t be much help.
Dear @habib
is there any news about your plugin.
Did I understand correctly that it should add Dewey DDC groups to a submission. I would be interested in that.
Best
Klaus
yes ist does, but it is mixed with other things, for example adding “status type” for Dini/Dnb. It is kind of a plugin only for admins (no settings for example), I never had time for things like that.
You can pm me if you want to.
Dear @habib
I’m working on a similar end. We might want to notify @carola about this to be intergrated to and get support by OJS-de.net · GitHub
Do you share the plugin on github?
I encountered the same issues discussed here and found solutions that might be useful for others facing similar challenges. I’ve divided my response into two parts: Schema and Form Field.
I am using ojs 3.3
Schema
I faced several challenges in this area, particularly with understanding how the items property works. After delving into the OJS files, specifically examining the function _convertStringsToSchema in \lib\pkp\classes\handler\APIHandler.inc.php , I realized that items need to be an object rather than an array. Therefore, I simply parsed the array to an object.
Form field
In this section, I encountered an issue where selecting one checkbox activated all checkboxes. The problem stemmed from the value property. Here’s the corrected code: