Add new validation key for custom fields

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
durangod
Registered User
Posts: 804
Joined: Tue Nov 03, 2009 1:26 pm
Location: USA East Texas
Name: Dave

Add new validation key for custom fields

Post by durangod »

If you want to understand the background for this please see here
viewtopic.php?t=2651524

The only difference between the native option and this option is that this option also includes spaces

For the validation it is not actually a bug because the option does not say it includes spaces (even thought maybe it should) so what i did was i added a new regex to the core files so i can select the new option from the ACP.


phpbb/profilefields/type/type_string_common.php
approx line 30

after this code

Code: Select all

               'LETTER_NUM_PUNCTUATION'	=> '[\p{Lu}\p{Ll}][\p{Lu}\p{Ll}0-9.,\-_]+',

add this code

Code: Select all

/* begin custom mod */
		'LETTER_NUM_PUNCTUATION_SPACES' => '[\p{Lu}\p{Ll}][\p{Lu}\p{Ll}0-9.,\-_\x20]+',
/* end custom mod */

save and close type_string_common.php

Next:

language/en/acp/profile.php
approx line 125

after this code

Code: Select all

	'LETTER_NUM_UNDERSCORE'		=> 'Any letters, numbers and underscores',

add this code

Code: Select all

/* begin custom mod */
	'LETTER_NUM_PUNCTUATION_SPACES' => 'Any letters, numbers, comma, dots, underscores, dashes, and spaces beginning with any letter',
/* end custom mod */

save and close profile.php


Next:

language/en/ucp.php
approx line 225

after this code

Code: Select all

	'FIELD_INVALID_VALUE'				=> 'The field “%s” has an invalid value.',

add this code

Code: Select all

/* begin custom mod */
	'FIELD_INVALID_CHARS_LETTER_NUM_PUNCTUATION_SPACES'  =>  'The field “%s” has invalid characters, only letter, number or _,-. characters and spaces are allowed and the first character must be alphabetic.',
/* end custom mod */

save and close ucp.php

all done! :)


I know that when just editing php files you dont have to clear cache but i do as a habbit whenever i make a change of any kind. So that is up to you.

Now you can select the last option on the drop down and it will store the new regex in the field.

Hope this helps.. :)
Username is short for durango dave

Return to “phpBB Custom Coding”