Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2250

phpBB Custom Coding • Add new validation key for custom fields

$
0
0
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:

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

add this code

Code:

/* 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:

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

add this code

Code:

/* 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:

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

add this code

Code:

/* 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.. :)

Statistics: Posted by durangod — Mon Mar 04, 2024 3:05 am



Viewing all articles
Browse latest Browse all 2250

Trending Articles