Displaying options of a plugin in backend

Hi @NateWr,

We have developed a plugin for Custom Meta Fiel to Submission Step 3. The data is successfully stored in submission_settings table. However, we use the following code block to call these settings to publication tab in backend. Value, Multilanguage option and the save button are not displayed. How can we fix this?

function addToPublicationForms($hookName, $params) {
	$smarty =& $params[1];
	$output =& $params[2];
	$submission = $smarty->get_template_vars('submission');
	$smarty->assign([
		'testField' => $submission->getData('testField'),
	]);

	$output .= sprintf(
	'<tab id="customMetadata" label="%s">%s</tab>', 'Test',
	$smarty->fetch($this->getTemplateResource('publication.tpl'))
	);
	
	return false;
}

Publication tpl code

{fbvFormSection label="plugins.generic.test.fieldName" required="1" validation="required" class="pkpFormFieldLabel required"}
	{fbvElement type="text" name="testField" multilingual=true id="testField" required="1" value=$testField validation="required" class="pkpFormField__input"}
{/fbvFormSection}

HI @peditor,

Can I share your question on the public forum? This ensures that the question and answer is available to other people who might have the same issue.

First, the new publication forms are not compatible with the old Form Builder Vocabulary, such as {fbvElement}. From 3.2 on, you need to use the form components. As an example, here is the form for the title and abstract:

In your function addToPublicationForms you would include code like this:

$customForm = new MyCustomForm(...);
$workflowData = $templateMgr->getTemplateVars('workflowData');
$workflowData['components']['customMetadata'] = $customForm->getConfig();
$workflowData['publicationFormIds'][] = 'customMetadata';
$templateMgr->assign('workflowData', $workflowData);
$output .= '
<tab id="customMetadata" label="Custom Metadata">
  <pkp-form v-bind="components.customMetadata" @set="set"></pkp-form>
</tab>
';

Second, it sounds like you are attaching the metadata to submission_settings. But if you are adding it to the publication forms, you may want to attach it instead to publication_settings. That’s because all of the publication forms are loaded separately for each version. In most cases, metadata should be attached to the publication (ie - the version) not the submission.

Third, if this is really metadata, you may find it easier to add a new field to the existing metadata form rather than to create your own tab and form. The example institutionalHome shows how to add data to the journal and add a field to the masthead form. The principles are the same for publications.

Instead of using the context schema at https://github.com/NateWr/institutionalHome/blob/master/InstitutionalHomePlugin.inc.php#L26 you would use the publication schema (Schema::get::publication).

And instead of checking for the FORM_MASTHEAD at https://github.com/NateWr/institutionalHome/blob/master/InstitutionalHomePlugin.inc.php#L73 you would check for FORM_METADATA.

In this way you can add your field to the existing metadata form and have it save to the publication.

Hi @NateWr,

Thank you so mush. Your explanation is very helpful for me.

Yes of course you can share public forum.

Thanks,

It looks like this post is already public, we’ll just move it to a category so others can see it.