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
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
aleskl
Posts: 110
Joined: Mon Apr 11, 2011 7:08 am

Make text field required in article submission

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

Hello!

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"?

Cheers,
Ales

JasonNugent
Site Admin
Posts: 910
Joined: Tue Jan 10, 2006 6:20 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).

Regards,
Jason

aleskl
Posts: 110
Joined: Mon Apr 11, 2011 7:08 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!

-Ales


Return to “OJS Technical Support”

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 2 guests