Mini89 Posted December 29, 2022 Share Posted December 29, 2022 i'm new to developing prestashop modules and could go a long way but now i'm stuck on the following, I am creating a form in the back office in which products can be searched. I would like to see that if I change the text in the textbox, the filter will immediately compare. I already have this code: public function renderForm(){ $fields_form = [ 'form' => [ 'legend' => ['title' => $this->l('Nieuw product toevoegen aan kast'), 'icon' => 'icon-file'], 'input' => [ [ 'type' => 'text', 'label' => $this->l('Product zoeken'), 'name' => 'product_search', 'desc' => $this->module->l('Welk product wil u toevoegen aan de kast'), 'hint' => $this->l('Als het product er niet tussen staat moet u deze eerst toevoegen aan de webshop'), 'required' => true, ], [ 'type' => 'text', 'label' => $this->l('Aantal in de kast'), 'name' => 'product_amount', 'desc' => $this->module->l('het aantal producten wat in de kast staat'), 'required' => true, ], [ 'type' => 'select', 'label' => $this->l('Product kiezen'), 'name' => 'product_name', 'options' => [ 'query' => $this->getImageSizes(), 'id' => 'name', 'name' => 'name', ], ], ], 'submit' => [ 'title' => $this->l('Save'), 'class' => 'btn btn-primary btn-mc pull-right', ], ], ]; return $helper->generateForm([$fields_form]); } private function getImageSizes() { $query = new DbQuery(); $query->select('id_product, name'); $query->from('product_lang'); //$query->where('name = "Glas"'); $result = array(); $compleet = array(); $result = Db::getInstance()->executeS($query); $search = Tools::getValue('product_search'); foreach ($result as $line){ if(str_contains(strtolower($line['name']), strtolower($search))){ $compleet[] = $line; } } try { return $compleet; } catch (Exception $exception) { $this->errors[] = $exception->getMessage(); return []; } } 1 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