For the location field for example, how would I capitalize every word using ucfirst in profile-modify.php:
'location' => array(
'type' => 'text',
'label' => $txt['location'],
'log_change' => true,
'size' => 50,
'input_attr' => array('maxlength="20"'),
'permission' => 'profile_extra',
text-transform: capitalize; works but not if caps lock or shift is on.
You can either do that via JS while the user types (which should be tricky, given how profile fields are actually shown and stored) or you can do it silently after submission, in Profile-Modify.php, somewhere in
// Save the profile changes.
function saveProfileFields()
{
On the foreach loop, you check if the current item is "location" and, if so, you apply your magic :P
Suggestion (untested)
'location' => array(
'type' => 'text',
'label' => $txt['location'],
'log_change' => true,
'size' => 50,
'permission' => 'profile_extra',
'input_validate' => create_function('&$value', '
$value = ucwords(strtolower($value));
return true;
'),
),
You can only have it do it while you type in JS, right? ucwords/first can't? It worked anyway so not that bothered. Thanks.
Correct, the solution I provided applies server side only. It wouldn't be impossible to do client side too, but there's always the fact that whatever happens on the client side can be trivially ignored by users, i.e. assume whatever happens on the client is still messed up by the time it gets to the server anyway.