Affiliation mandatory, OJS 3.0.1.0

Is it possible to put affiliation as mandatory for contributors/authors?

Thanks

1 Like

Hi @vvucic,

That’ll require a modification for the moment. We frequently get requests for various fields to be made optional if they’re required, or required if they’re optional, and we’re not going to make everyone happy on that – we may add flags to control the required status of these fields, but I can’t promise that just yet.

Regards,
Alec Smecher
Public Knowledge Project Team

I will be happy if I will be instructed which file to modify in order to get that done. I understand that it is time consuming to make everyone happy.

Thanks

Hi @vvucic,

The form responsible for the author form is implemented in lib/pkp//pkp/controllers/grid/users/author/form/AuthorForm.inc.php, and the corresponding template is lib/pkp/templates/controllers/grid/users/author/form/authorForm.tpl. Have a look at the existing fields as an example of how to require additional ones.

Regards,
Alec Smecher
Public Knowledge Project Team

I added line in lib/pkp//pkp/controllers/grid/users/author/form/AuthorForm.inc.php
$this->addCheck(new FormValidator($this, ‘affiliation’, ‘required’, ‘form.affiliationRequired’));
and in lib/pkp/templates/controllers/grid/users/author/form/authorForm.tpl
I added line affiliationRequired=true
after countryRequired=true
But I still do not have affiliation marked as mandatory.
Please advise.
Thanks

1 Like

Hi @vvucic,

You’ll also need to add support for the affiliationRequired flag to lib/pkp/templates/common/userDetails.tpl as well.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Just got it :slight_smile:
see screenshot

Hi! @vvucic and @asmecher

Is it possible for me to indicate the code that I should include in lib/pkp/templates/common/userDetails.tpl to add support for the affiliationRequired?

I have included the modified code presented by @vvucic in lib/pkp//pkp/controllers/grid/users/author/form/AuthorForm.inc.php, and the corresponding template is lib/pkp/templates/controllers/grid/users/author/form/authorForm.tpl

But I’m not sure how to continue … What is the code required in lib/pkp/templates/common/userDetails.tpl to make the data mandatory “affiliation”.

I also thank @astevens for his great help and good response on this subject in:

Thank you very much!

I can send you tpl files that I edited. OK?

1 Like

Hi @asmecher,

I am wandering if there is a way to make an attribute mandatory for several languages? That means in a journal that uses two languages that an attribute has to be specified in both languages, not just the primary one.

Best regards, Primož

This is how file userDetails.tpl looks in my installation in which I set that affiliation is mandatory.

The rest is related to procedure that I described. here it is again:
I added line in lib/pkp//pkp/controllers/grid/users/author/form/AuthorForm.inc.php
$this->addCheck(new FormValidator($this, ‘affiliation’, ‘required’, ‘form.affiliationRequired’));
and in lib/pkp/templates/controllers/grid/users/author/form/authorForm.tpl
I added line affiliationRequired=true
after countryRequired=true

Please describe in more details what you want to accomplish. Please try to describe concrete scenario/situation.

Thanks

Hi @vvucic

Concrete example, easy: Imagine you have a journal that supports English and Slovene languages, English as a primary. I would like to make mandatory that a submitter provides an issue title in both languages, English and Slovene. And similar to other metadata (keywords, abstract,…).

Best regards, Primož

In OJS 3.1 you can choose which metadata fields are mandatory. Please check that.

1 Like

Hi… @vvucic… thanks… You can me the TPL to my email is davidyoriana@gmail.com

Thanks for help me!

The content is in pastebin link I put above. If you cannot find it I will paste it again.

1 Like

@vvucic
Thanks!!!

Hi @vvucic, @asmecher,
I would like to make “affiliation” and “biography” a “required” field in “article contributors” form.

I have made changes as described above in all three files:

  1. In AuthorForm,inc.php, I added
$this->addCheck(new FormValidator($this, 'affiliation', 'required', 'form.affiliationRequired'));
$this->addCheck(new FormValidator($this, 'biography', 'required', 'form.biographyRequired'));
  1. In AuthorForm.tpl, I added
affiliationRequired=true
biographyRequired=true
  1. In UserDetails.tpl, I added codes at two places:
a.  {if $affiliationRequired}
		{assign var="affiliationRequired" value=true}
	{else}
		{assign var="affiliationRequired" value=false}
	{/if}
	
    {if $biographyRequired}
		{assign var="biographyRequired" value=true}
	{else}
		{assign var="biographyRequired" value=false}
	{/if}

and
b. (only the bold codes below)
{fbvFormSection for=“affiliation”}
{fbvElement type=“text” label=“user.affiliation” multilingual=“true” name=“affiliation” id=“affiliation” required=$affiliationRequired value=$affiliation inline=true size=$fbvStyles.size.LARGE}
{/fbvFormSection}

{fbvFormSection}
{fbvElement type=“textarea” label=“user.biography” multilingual=“true” name=“biography” id=“biography” required=$biographyRequired rich=true value=$biography}
{/fbvFormSection}

Now, in the user form, I get both the fields as “required”
image

But, only the affiliation field behaves as “truly required”. If I leave it empty and try to save the form, it shows the error and get stuck to the field.
However, in case of biography, even if I leave it blank and save the form, its throws and message “the field is required” immediately saves it successfully.

What am I missing here?

Best regards,

1 Like

Hi @anupent,

You’ll need to use FormValidatorLocale for localized fields.

Regards,
Alec Smecher
Public Knowledge Project Team

2 Likes

Thank you @asmecher,
Its working now.

best regards,

1 Like