OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Including mailing address as a required field

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

Moderators: jmacgreg, michael, John

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

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. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

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 OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Including mailing address as a required field

Postby RickMath » Mon Mar 29, 2010 9:06 pm

Hi

I know that there are many posts on making fields on the forms to create user account and user profile forms. I have edited the tpl files to include required="true" in both. I also have looked at the classes files to check the fields for required.

What I do not know is the format for the check lines for mailing address in the classes files such as CreateAccountForm.inc.php and ProfileForm.inc.php

Specifically, I am not sure how to add a line similar to this

$this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired'));

for the mailing address. Should it read user.profile.form.mailingaddressRequired ?

Hope you do not mind me posting a new thread on this. Sorry to be such a nervous Nelly but I am cautious.

Thanks as always for your advice. :D

Rick
RickMath
 
Posts: 245
Joined: Fri Feb 27, 2009 12:30 am

Re: Including mailing address as a required field

Postby wbt » Thu Apr 01, 2010 2:10 pm

Hi Rick,

You should use FormValidator for this, not FormValidatorEmail. The third argument of the constructor of FormValidator should be a key from the locale.xml file. So if you add
Code: Select all
$this->addCheck(new FormValidator($this, 'mailingAddress', 'required', 'user.profile.form.mailingAddressRequired'));

to createAccount.tpl, you should add
Code: Select all
<message key="user.profile.form.mailingAddressRequired">A mailing address is required.</message>

to locale/en_US/locale.xml.

Regards,

Wouter
wbt
 
Posts: 14
Joined: Thu Nov 12, 2009 1:25 pm

Re: Including mailing address as a required field

Postby RickMath » Thu Apr 01, 2010 2:33 pm

:D Hey Wouter

Thanks I will try that later tonight and let you know how it works.

I appreciate your response.

Rick
RickMath
 
Posts: 245
Joined: Fri Feb 27, 2009 12:30 am

Re: Including mailing address as a required field

Postby RickMath » Thu Apr 01, 2010 7:07 pm

Wouter

Your suggested changes worked. Yea!!!!

My only comment for others that may read this post, is that the addcheck line should go in ocs/classes/user/form/CreateAccountForm.inc.php

It also works in ..../form/ProfileForm.inc.php

At least in my version of OCS this is where they worked.

Thanks as always for your help.

A nice feature would be a requirement for all the elements of a full mailing address. Maybe this is beyond us. Seems that anything but a null entry in the mailing address box will satisfy the check.

You are superstar on modifications to OCS.

Rick :D
RickMath
 
Posts: 245
Joined: Fri Feb 27, 2009 12:30 am


Return to OCS Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest