How do I make a field not mandatory?

Hi
When our users want to register in one of our journals they have to fill out the Affiliation and Country fields.

mandatory
How can I remove the mandatory demand?
Regards
Niels Erik

Hi @nef,

What version of OJS are you using? (Please include this in your posts.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec
We’re using 3.1.1.2
Regards
Niels Erik

Hi @nef,

To make a mandatory field optional, or vice versa, you’ll need to edit both the form class (when the check is enforced on the server side) and the template (where the required status is flagged in the user interface). For the registration form, that is…

  • lib/pkp/classes/user/form/RegistrationForm.inc.php:
    $this->addCheck(new FormValidator($this, 'country', 'required', 'user.profile.form.countryRequired'));
  • lib/pkp/templates/frontend/components/registrationForm.tpl (or the equivalent template in your theme):
    <div class="country">
                          <label>
                                  <span class="label">
                                          {translate key="common.country"}
                                          <span class="required">*</span>
                                          <span class="pkp_screen_reader">
                                                  {translate key="common.required"}
                                          </span>
                                  </span>
                                  <select name="country" id="country" required>
                                          <option></option>
                                          {html_options options=$countries selected=$country}
                                  </select>
                          </label>
                  </div>
    

Regards,
Alec Smecher
Public Knowledge Project Team