Hello all, @asmecher, @rcgillis , @NateWr ,
Description of issue or problem I’m having:
I’m in need of making userUrl and biography fields mandatory. I understood how to use the formValidatorLocale while I was writing this message. So, apparently making the fields mandatory is working correctly. Please check if everything is fine or if I missed something.
During my testing I came up with other problems to solve:
-
I’m unable to display the * sign on the required fields
-
There’s a translation text being displayed that is nowhere to be found in locale files.
The content is apparently from key validator.filled or validator.required, as the values are the same in English. But, the text that is displayed in the contributor form in Portuguese doesn’t exist in our translation files. The content in locale files is “Campo obrigatório”, but “Este campo é requerido.” is being shown. What’s going on?
Steps I took leading up to the issue:
I searched the forum and found a few ideas here to make fields mandatory, but the * sign on the label is not showing, although validation seems to be working. I couldn’t find the code to add the with the required=“true”… It seems to be from a different version.
What I tried to resolve the issue:
In: controllers/grid/users/author/form/PKPAuthorForm.inc.php
$this->addCheck(new FormValidatorUrl($this, 'userUrl', 'required', 'user.profile.form.urlInvalid'));
AND
$this->addCheck(new FormValidatorLocale($this, 'biography', 'required', 'user.profile.form.biographyRequired', $this->defaultLocale));
In: templates/common/userDetails.tpl
I set
{if $userUrlRequired}
{assign var="userUrlRequired" value=true}
{else}
{assign var="userUrlRequired" value=false}
{/if}
{fbvElement type="text" label="user.url" name="userUrl" id="userUrl" value=$userUrl maxlength="255" inline=true size=$fbvStyles.size.SMALL required=$userUrlRequired}
AND
{if $biographyRequired}
{assign var="biographyRequired" value=true}
{else}
{assign var="biographyRequired" value=false}
{/if}
{fbvElement type="textarea" label="user.biography" multilingual="true" name="biography" id="biography" rich=true value=$biography required=$biographyRequired}
Application Version - e.g., OJS 3.1.2:
I’m trying this on OJS 3.3.0.7.
Is there anything else I need to do or this would be enough?
Additional information, such as screenshots and error log messages if applicable:
Figure 1 - Initial error messages seem ok, except that “Este campo é requerido.” doesn’t exist in locale files