How can I override the edit publication form?

I am developing an OJS theme for OJS 3.3.0.8.

in my theme there are several customizations, in particular I added two new fields to the submission.

I was able to modify the submission entry form in this way:

I have overridden the tpl
submission/form/submissionMetadataFormTitleFields.tpl
where I added 2 new textareas belowe abstract textarea

I added 3 hooks:
submissionsubmitstep3form :: initdata
submissionsubmitstep3form :: readuservars
Publication :: edit
to init the form, read the input values and save them on submit

I also added the 2 new fields to the schema using this hook
Schema :: get :: publication

In that part (entering a submission) everything worked fine.

On the other hand, I am not able to complete the work and introduce the 2 new fields in the publication modification form too (the one that is used to publish the submission, see the screenshot).
Schermata 2022-09-28 alle 11.11.22
I can’t find the tpl where to override the form.

It seems to me that it doesn’t really exist and that in reality that form is rendered only in the dom by a javascript.

Can anyone give me some suggestions?

Hi, @nostrabramus,

Take a look at the Template::Workflow::Publication hook and example from the plugin that interacts with it: JATSParserPlugin/JatsParserPlugin.inc.php at b9fda2836f18c9e03a2e3995474b57bcabf833c5 · Vitaliy-1/JATSParserPlugin · GitHub. Inside this method, you can find a reference to example of a template file, to which Vue.js is binded and example of the form creation and initialization.

Regarding UI library: https://docs.pkp.sfu.ca/dev/documentation/en/frontend-ui-library (if using predefined forms, no need to build anything with Vue.js)
Regarding new forms: https://docs.pkp.sfu.ca/dev/documentation/en/frontend-forms

Let me know if you have further questions

1 Like

Hi @Vitaliy,
thank you very much for your answer.

Following your suggestions I was able to add my two new fields using the hook:

HookRegistry::register('Form::config::before', array($this, 'initPKPTitleAbstractForm'));

and hooking the function to it

	public function initPKPTitleAbstractForm(string $hookName, FormComponent $form){
		// Only modify the formtitleabstractform form
		if (!defined('FORM_TITLE_ABSTRACT') || $form->id !== FORM_TITLE_ABSTRACT) {
			return;
		}
		$form->addField(new FieldRichTextarea('newfield1', [
				'label' => __('article.newfield1'),
				'isMultilingual' => true,
				'value' => '',
			]));
		$form->addField(new FieldRichTextarea('newfield2', [
			'label' => __('article.newfield2'),
			'isMultilingual' => true,
			'value' => '',
		]));

    	return false;
	}

as shown in the second method for modifying forms proposed by the documentation: https://docs.pkp.sfu.ca/dev/documentation/en/frontend-forms

As always, your help was invaluable.

Best regards

Abramo

Thanks for the feedback, glad that it worked!