Editor convert odd characters to upper fails...
Editor convert odd characters to upper fails...
In my editor php file I'm saving a dummy pasword when a new user is created. I take the first letter of the firstname and the first of the lastname and add the employeenumber.
However, in Sweden we use the characters å, ä and ö. If the username first or last, starts with any of those they will become question marks (?) in the database. These letters works everywhere else. THe firstname and lastname field will have the correct letters in the db.
I'm making the password letters upper case though, I've tried a bunch of different methods: Normal strtoupper() and as you see in the code below mb_strtoupper and mb_convert_case(). None of them work....
I have tested these upper case methods in another piece of code and they work fine, so I wonder if there's something in the DT code under the hood that does something?
Here's the snippet of code, on precreate in the php page:
->on( 'preCreate', function ( $editor, $values ) {
$editor
->field( 'users.user_pwd' )
//->setValue(password_hash('qwe345', PASSWORD_DEFAULT));
->setValue(mb_convert_case(substr($values['users']['user_fname'], 0, 1), MB_CASE_UPPER, 'UTF-8')
. mb_strtoupper(substr($values['users']['user_lname'], 0, 1), 'UTF-8')
. trim($values['users']['user_employee']));
} )
This question has an accepted answers - jump to answer
Answers
OK, found the issue. Had to use the mb_ extension on BOTH strtoupper and substr:
Good old PHP! Thanks for posting back - good to hear you have it working now.
Allan