[email protected] Posted August 23, 2013 Share Posted August 23, 2013 (edited) Hi Prestashop Gurus,I would like to include numerical characters in the Last Name field, during registration (which is currently blocked for any characters other than alphabetics)Anyone has any idea?Many ThanksIan Edited January 6, 2014 by [email protected] (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 24, 2013 Share Posted August 24, 2013 Hi Gless,do this:edit file /classes/Validate.phpfind the code for isName:/*** Check for name validity** @param string $name Name to validate* @return boolean Validity is ok or not*/public static function isName($name){return preg_match(Tools::cleanNonUnicodeSupport('/^[^0-9!<>,;?=+()@#"째{}_$%:]*$/u'), stripslashes($name));}Copy this block (copy just below itself) and change this (red text) in the copy:/*** Check for name validity but allow numbers** @param string $name Name to validate* @return boolean Validity is ok or not*/public static function isNameWithDigits($name){return preg_match(Tools::cleanNonUnicodeSupport('/^[^!<>,;?=+()@#"째{}_$%:]*$/u'), stripslashes($name));}(I took out the'/^[^0-9!<>,;?=+()@#"째{}_$%:]*$/u'0-9 from the original string)save the file.Then edit classes/Customer.php and find: Add red text)public static $definition = array('table' => 'customer','primary' => 'id_customer','fields' => array('secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false),'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isNameWithDigits', 'required' => true, 'size' => 32),'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),and save the fileFinally edit file classes/Address.php and find (Ad red text):public static $definition = array('table' => 'address','primary' => 'id_address','fields' => array('id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64),'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isNameWithDigits', 'required' => true, 'size' => 32),'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),and save the file.I think that's it. try to play with it a little (edit customer one more time after registration etc. as I didn't do that)pascal Link to comment Share on other sites More sharing options...
[email protected] Posted January 6, 2014 Author Share Posted January 6, 2014 thanks pascal! works really nicely! Ian Link to comment Share on other sites More sharing options...
[email protected] Posted February 2, 2014 Author Share Posted February 2, 2014 Hi Pascal, With the recent modification, I learned that it has somehow affected some buttons in my backend statistics part (as shown in the attached picture). Whenever I hit the button for the statistic, it shows errors, and another Prestashop [spam-filter] has found that it may be because of the modification in validity.php file: "public static function isNameWithDigits($name)" Will you be able to help further? Thanks Ian Link to comment Share on other sites More sharing options...
PascalVG Posted February 8, 2014 Share Posted February 8, 2014 As the Error mentions on first line, it seems that the Validation function "isName" cannot be found. Did you make any modifications to the file? Maybe you forgot a } or so, which then messes up the functions after that? Just a wild guess... Can you otherwise show me the change/addition you made or add the full Validate.php file so I can have a look? (please mention PrestaShop version) pascal. Link to comment Share on other sites More sharing options...
PascalVG Posted February 8, 2014 Share Posted February 8, 2014 Ian, On second thoughts.... can it be that you didn't copy the isName function, but directly modified that function itself to function isNameWithDigits? Then you don't have any isName function any more, giving this error.... Let me know, pascal. Link to comment Share on other sites More sharing options...
[email protected] Posted February 9, 2014 Author Share Posted February 9, 2014 Hi Pascal Sorry for the delayed in my reply. I think I did ended up doing the "directly modified" to the isName function... Perhaps that is the problem? SHould I have added the isNameWithDigits below isName instead? Thanks Ian Link to comment Share on other sites More sharing options...
PascalVG Posted February 9, 2014 Share Posted February 9, 2014 Hi Ian,Yes indeed. I wrote, maybe too small, copy the isName function and add just below it. Then change the copy to isNameWithDigits :-)So try to re-add the isName function and you should be good again :-)Let me know,Pascal Link to comment Share on other sites More sharing options...
[email protected] Posted February 10, 2014 Author Share Posted February 10, 2014 It works fine now Pascal.. thanks for your help... Sorry I didn't read your instruction properly.. Again.. thanks! Ian Link to comment Share on other sites More sharing options...
PascalVG Posted February 11, 2014 Share Posted February 11, 2014 Hi Ian, no problem. Good to hear it's solved! Happy selling, pascal Link to comment Share on other sites More sharing options...
vertix Posted May 3, 2022 Share Posted May 3, 2022 Hello, is there a way to do this on version 1.7.8? Thank you 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