For example, OJS 3.4
Additional information
I’m writing new plugin for my needs. Plugin adds new Field (FieldAutosuggestPreset) to publication form. value should be an array (can be empty). i have issue with showing this field in workflow (publication tab). There, if publication don’t have record in DB (table publication_settings) with value "[ ]"
new field is not showing up because of JS error when trying check length of null.
full error:
TypeError: Cannot read properties of null (reading 'length')
at a.updateInputWidth (build.js?v=3.4.0.5:344:105829)
at a.mounted (build.js?v=3.4.0.5:344:106467)
at On (build.js?v=3.4.0.5:319:25861)
at sn (build.js?v=3.4.0.5:319:23404)
at Object.insert (build.js?v=3.4.0.5:319:35383)
at E (build.js?v=3.4.0.5:319:52681)
at Xr.__patch__ (build.js?v=3.4.0.5:319:53997)
at e._update (build.js?v=3.4.0.5:319:21016)
at Xr.r (build.js?v=3.4.0.5:319:21762)
at e.get (build.js?v=3.4.0.5:319:28406)
migration isn’t solution b/c its only adding empty array as value only for existing publication (we also can add new ones by import or quick submit plugin)
So in that case i need a way to define default value for this field if it is not present in DB.
in “Form::config::before” hook i have defined value (even if not exists) and in first submission creation form it’s working correctly.
is there a way to add default value in hook “Schema::get::publication” when adding field to schema ?
$schema->properties->{'myNewField'} = (object)[
'type' => 'array',
'items' => (object) [
'type' => 'string',
'validation' => ['string'],
],
'multilingual' => false,
'apiSummary' => true,
'validation' => ['array'],
'default' => [],
];
tried that way and it didn’t work. any clues ?