You are viewing the PKP Support Forum | PKP Home Wiki

Make text field required in article submission

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Make text field required in article submission

Postby aleskl » Fri Feb 01, 2013 5:52 am


I would like to make the text field "Comments for the editor" required in paper submission Step 1. I added required="true" to the label of the field, which shows an asterisk by the field label, but I'm lost how to actually check this field for content. I did search the forum, found some instructions for form checking, but I don't know how to apply this to the submission template "step1.tpl"?

Posts: 110
Joined: Mon Apr 11, 2011 7:08 am

Re: Make text field required in article submission

Postby JasonNugent » Fri Feb 01, 2013 7:09 am

Hi Ales,

The validation is done server side, in the Form class that handles that particular form. In your case, you'd want to edit classes/author/form/submit/AuthorSubmitStep1Form.inc.php and look in the constructor at the top of the form. You'll see a few calls to $this->addCheck() where a few FormValidator objects are passed. You'd have to add one for the field you want to make required (and probably also a locale key for the message you want to display if it is left blank).

Site Admin
Posts: 910
Joined: Tue Jan 10, 2006 6:20 am

Re: Make text field required in article submission

Postby aleskl » Mon Feb 04, 2013 3:15 am

Thank you Jason!

Your instructions were most helpful, I managed to enable the checking of Comments to the Editor in the classes/author/form/submit/AuthorSubmitStep1Form.inc.php. I added
Code: Select all
$this->addCheck(new FormValidator($this, 'commentsToEditor', 'required', 'author.submit.comments'));

For the error message I just used the modified text from the locale that goes with this field.

We use this field to enter the cover letter that is obligatory for the submission, so the checking of this is important. Thank you!

Posts: 110
Joined: Mon Apr 11, 2011 7:08 am

Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 4 guests