Jump to content

Tools::getValue() not working as intended


luky0

Recommended Posts

Hi i'm trying to get a data from a form with Tools::getValue() but i've got no response.

if(Tools::isSubmit('action'))
        {
            // Registra nella sessione la posizione
            $act = Tools::getValue('action');

            $response['to'] = $act;

            $fld = ["gps_formatted","gps_locality",
            "gps_admin3","gps_admin2","gps_admin1",
            "gps_country","gps_postal_code","gps_dist","gps_step",
            "gps_lat","gps_lon","filtro_categotria"];
            if($act == "setsession" || $act == "blank") {
                $usr = [];    

                foreach($fld as $key) {
                    if($act == "blank") {
                        $usr[$key] = "";
                    } else {
                        $usr[$key] = Tools::getValue($key);
                    }
                }
                $response['done'] = $this->setUserLocation($usr);    
            } else if($act == "radius") {
                $response['setRadius'] = $this->setRadius(Tools::getValue('gps_dist'), Tools::getValue('gps_step'));    
                $response['radius'] = Tools::getValue('gps_dist');    
                $response['step'] = Tools::getValue('gps_step');    
            } else if($act == "categories") {
                $sql = 'SELECT c.*, cl.name, cl.description from ' 
                        . _DB_PREFIX_ . 'category c inner join ' 
                        ._DB_PREFIX_ . 'category_lang cl on c.id_category = cl.id_category  where c.is_location=1'
                        . ' and cl.id_lang =' . $this->context->cookie->id_lang;
                $response = Db::getInstance()->executeS($sql);
            } else if($act == "store") {                   
                Context::getContext()->cookie->__set("extra_value", Tools::getValue('data'));
                $response['ok'] = true;    
            } else if($act == "retrieve") {                
                $response['data'] = Context::getContext()->cookie->__get("extra_value");    
            } 
            $response["filtrocategoria"]=$this->setCategoria(Tools::getValue('filtro_categoria')); 
            // var_dump(Tools::getValue('filtro_categoria'));
            // $response["filtrocategoria"]=$this->setCategoria("546"); 
        }

as you see there are others getValue but the last won't work... what did i do wrong? ps i'm modifing another dev code and i cannot ask.

i've tried to set a data in the "hard way" and that works fine.

i'm currently working with PS 1.7.6.1 and unfortunally i cannot change.

Thank you for your patience!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...