CPF - Auto upper case on registration

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Scam Warning
Post Reply
deanmoke
Registered User
Posts: 23
Joined: Tue May 20, 2008 9:05 am

CPF - Auto upper case on registration

Post by deanmoke » Tue Jun 16, 2015 10:52 am

Hi,
I have several custom profile fields on my install and need to ensure that some of these fields start with an upper case letter. This can either use ucfirst to correct the fields or force the user to enter the field correctly via validation.
Can anyone help?
Thanks,
Dean

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: CPF - Auto upper case on registration

Post by javiexin » Tue Jun 16, 2015 2:13 pm

This will definitely need an extension, as none of these things can be configured as it is, and not so easy as it may seem.

However, the easiest way (by far) to do this would be to add a validation entry in phpbb/profilefields/type/type_string_common.php around line 31, that will force a capital first letter, and then add two language entries, one in language/en/acp/profile.acp, with the name and explanation of the new validation rule, and another in language/en/ucp.php with the FIELD_INVALID_CHAR_xxx key, explaining why this validation failed.

But, as I said, this is not recommended... Do this only if you know what you are doing.

-javiexin

deanmoke
Registered User
Posts: 23
Joined: Tue May 20, 2008 9:05 am

Re: CPF - Auto upper case on registration

Post by deanmoke » Thu Jun 18, 2015 11:22 am

Thanks for the help Javiexin.
However, I can't find a validation entry that works (I've tried a couple I found online but they don't work).
Can you suggest anything?
Thanks,
Dean

Alpha Kitten
Registered User
Posts: 48
Joined: Sun May 24, 2015 9:17 am

Re: CPF - Auto upper case on registration

Post by Alpha Kitten » Thu Jun 18, 2015 12:40 pm

You can also display it with css .
open:

Code: Select all

common.css
find:

Code: Select all

.left-box.profile-details {
add:

Code: Select all

text-transform:capitalize;
but not after:

Code: Select all

}
Then save.

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: CPF - Auto upper case on registration

Post by javiexin » Thu Jun 18, 2015 5:31 pm

Alpha Kitten wrote:You can also display it with css .
The key here is display, this only changes the display, not the value actually stored in the database. And it shows it for every profile field (regardless of your decission), and only in one place...
deanmoke wrote:Can you suggest anything?
Not tested it, but I would say that if you prepend [A-Z] or [\p{Lu}] to all the existing validations, and replace the last + by a *, you would get something that would work. As I said, not tested!
I give you here some examples of what I would try. From these:

Code: Select all

		'ALPHA_ONLY'		=> '[a-zA-Z0-9]+',
		'LETTER_NUM_ONLY'			=> '[\p{Lu}\p{Ll}0-9]+',
		'LETTER_NUM_PUNCTUATION'	=> '[\p{Lu}\p{Ll}][\p{Lu}\p{Ll}0-9.,\-_]+',
I would create:

Code: Select all

		'CAPITALIZED_ALPHA_ONLY'		=> '[A-Z][a-zA-Z0-9]*',
		'CAPITALIZED_LETTER_NUM_ONLY'			=> '[\p{Lu}][\p{Lu}\p{Ll}0-9]*',
		'CAPITALIZED_LETTER_NUM_PUNCTUATION'	=> '[\p{Lu}][\p{Lu}\p{Ll}0-9.,\-_]+',
Hope these work, and help. Best regards,
-javiexin

Post Reply

Return to “Extension Requests”