Open Presta Posted November 29, 2013 Share Posted November 29, 2013 hello, i need to use this syntexe : foreach ($_POST AS $key => $value) but the addons developper ask me to change to Tools::getvalue but this function need a parameter shoold i overrite new fonction of getvalue ? Link to comment Share on other sites More sharing options...
bellini13 Posted November 29, 2013 Share Posted November 29, 2013 you need to provide more information. what are you trying to accomplish in the foreach section? You can't just replace a foreach section with a Tools::getValue function. Link to comment Share on other sites More sharing options...
Open Presta Posted November 29, 2013 Author Share Posted November 29, 2013 public function copyFromPost() { $languages = Language::getLanguages(false); $arrayTypelayer = array(); foreach ($_POST AS $key => $value) { if (key_exists($key, $this) AND $key != 'id_'.$this->table) { if($key == 'content') { .... $_POST should be replaced with Tools::getValue() but getvalue need to have a parameter Link to comment Share on other sites More sharing options...
bellini13 Posted November 29, 2013 Share Posted November 29, 2013 You should respond to them stating you are doing exactly what Prestashop does in their AdminController. In this case, Tools::getValue is not applicable and could not be used protected function copyFromPost(&$object, $table) { /* Classical fields */ foreach ($_POST as $key => $value) if (key_exists($key, $object) && $key != 'id_'.$table) { /* Do not take care of password field if empty */ if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) continue; /* Automatically encrypt password in MD5 */ if ($key == 'passwd' && !empty($value)) $value = Tools::encrypt($value); $object->{$key} = $value; } /* Multilingual fields */ $rules = call_user_func(array(get_class($object), 'getValidationRules'), get_class($object)); if (count($rules['validateLang'])) { $languages = Language::getLanguages(false); foreach ($languages as $language) foreach (array_keys($rules['validateLang']) as $field) if (isset($_POST[$field.'_'.(int)$language['id_lang']])) $object->{$field}[(int)$language['id_lang']] = $_POST[$field.'_'.(int)$language['id_lang']]; } } Link to comment Share on other sites More sharing options...
Open Presta Posted November 29, 2013 Author Share Posted November 29, 2013 bizarre , pourtant c'est un message de l'équipe d'addons et je veux pas que j'ajoute un override pour le module car c'est un peu compliquer pour les simples users Link to comment Share on other sites More sharing options...
bellini13 Posted November 30, 2013 Share Posted November 30, 2013 English on the English forum 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