leeloo Posted November 18, 2010 Share Posted November 18, 2010 When a customer signs up, his lastname is recorded in the table customers and addresses in uppercase.The firstname is written such that the client has entered.Then in my authentification.tpl, i put a style in the input tag input onkeyup="$('#firstname').val(this.value);" type="text" class="text" style="text-transform: uppercase;" id="customer_firstname" name="customer_firstname" value="{if isset($smarty.post.customer_firstname)}{$smarty.post.customer_firstname}{/if}" /> It's work but not in database.How to force registration of the firstname in uppercase in the database ?I voluntarily removed the opening tag < because it does not go to the forum Link to comment Share on other sites More sharing options...
Zenith Posted December 6, 2010 Share Posted December 6, 2010 In "classes/Customer.php" ...Find: $fields['firstname'] = pSQL($this->firstname); Replace with: $fields['firstname'] = pSQL(Tools::strtoupper($this->firstname)); This coverts all characters to uppercase before adding it to the database You can also apply this modification to "classes/Address.php" so the first name of the address is formatted the same. Link to comment Share on other sites More sharing options...
leeloo Posted December 6, 2010 Author Share Posted December 6, 2010 Yes,Thank's Zenith Link to comment Share on other sites More sharing options...
davers44 Posted August 28, 2011 Share Posted August 28, 2011 I'm trying to do the same thing but having only the first letter uppercase of each word, I tried the ucwords function but no luck, strtoupper works but ucwords not. Any idea? Many customers write everything in lowercase but I'd like my database and invoice tidy. Thanks Link to comment Share on other sites More sharing options...
davers44 Posted November 13, 2011 Share Posted November 13, 2011 I even tried with "ucfirst" function and works correctly but only the first word of the string and not each word of the string like "ucwords" function should do. They should be all valid php functions, any idea why all works exempt the one I need? http://www.php.net/m....strtoupper.php http://www.php.net/m...ion.ucfirst.php http://php.net/manua...ion.ucwords.php WIth ucwords I get this: Fatal error: Call to undefined method Tools::ucwords() in .../classes/Customer.php on line 127 Link to comment Share on other sites More sharing options...
mrzoom Posted November 13, 2011 Share Posted November 13, 2011 When using ucwords you first need to make all the letters to lower first. ucwords only do the change to the first letter in each word so if the rest already are upper they will stay upper. $test = "hELLO"; ucwords(strtolower($test)); // This will make it to Hello Link to comment Share on other sites More sharing options...
davers44 Posted November 14, 2011 Share Posted November 14, 2011 That would make sense but the problem is that that while other function like ucfirst or strtoupper are recognized by the system and works correctly, the function ucwords is not even recognized at all no matter how I configure it. Strange thing as all three seems valid PHP tools. $fields['firstname'] = pSQL(Tools::strtoupper($this->firstname)); WORKS $fields['firstname'] = pSQL(Tools::ucfirst($this->firstname)); WORKS $fields['firstname'] = pSQL(Tools::ucwords($this->firstname)); FATAL ERROR* *Fatal error: Call to undefined method Tools::ucwords() in .../classes/Customer.php on line 127 Link to comment Share on other sites More sharing options...
mrzoom Posted November 15, 2011 Share Posted November 15, 2011 Tools is an object in prestashop and it looks like they haven't build a Tools::ucwords. But i think you can use the real php function like this: $fields['firstname'] = pSQL(ucwords($this->firstname)); Link to comment Share on other sites More sharing options...
davers44 Posted November 29, 2011 Share Posted November 29, 2011 Well, I think you got it right, thanks a lot, I apprecieted your help! I think this should be standard in any Prestashop release. Link to comment Share on other sites More sharing options...
jimi007 Posted February 3, 2015 Share Posted February 3, 2015 not working in PS 1.6 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now