Council for the text string formatter

georgie

Member
Hello

I would like to format a string, when it is submitted in a form.

This is about two fields name and surname. I wish that all the words are in lower case except the first letter of each word, in upper case.

Where can I implement my code?

I had thought of "input mask" or "format string" from the options of the relevant fields? A PHP code in the form of plugin?

Thank you for all council
 
You can use php validations with replace or a php form plugin (onBeforeStore) with something like strtolower() and ucfirst()
 
Hi

Yes ! It runs but with "Start of form submission - OnBeforeProcess".

I use this code, it runs also with '-', but not for ?, ?, ?...

Code:
$var_name = $formModel->formData['rohm_users___name']; 
$var_lastname = $formModel->formData['extra_fields___lastname_user'];

$formModel->updateFormData('rohm_users___name', mb_convert_case($var_name, MB_CASE_TITLE) , true);
$formModel->updateFormData('extra_fields___lastname_user', mb_convert_case($var_lastname, MB_CASE_TITLE) , true);

But already, it is very nice !
 
I didn't try, maybe $str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8"); will help.
 
Yes, thanks, it is better !!!

But not perfect :rolleyes: ...

Indeed, "???-?aa" gives "???-?aa", nice ! Thank you for that, it was not possible without the "UTF-8" argument.

But "V??ga" no changes, and gives "V??ga"...
 
Thanks

It is again better, but always not perfect...

Indeed, "V??g?" give "V??g?".

But no problem, it is already very nice !
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top