Jump to content

dropdown menu in module configuration


Recommended Posts

Hello,

I am trying to add a dropdown menu to the configuration of a custom module. I need it to have customer names as values and when an option is selected, to display a table with data from the database. 

So I have a function which looks like that:

    public function renderForm()
    {

        $sql = '
           SELECT
	product_id, product_name, product_quantity,  product_price, ps_orders.id_order
FROM
	`ps_orders`
	LEFT JOIN ps_order_detail ON ps_orders.id_order = ps_order_detail.id_order 
WHERE
	ps_orders.id_customer = 2;
            ';

        if ($result = Db::getInstance()->executeS($sql)) {
            $this->fields_list = array(
                'product_id' => array(
                    'title' => 'ID',
                    'width' => 'auto',
                    'type' => 'id'
                ),
                'product_name' => array(
                    'title' => 'product name',
                    'width' => 'auto',
                    'type' => 'text'
                ),
                'product_quantity' => array(
                    'title' => 'quantity',
                    'width' => 'auto',
                    'type' => 'text'
                ),
                'product_price' => array(
                    'title' => 'price',
                    'width' => 'auto',
                    'type' => 'id'
                ),
                'id_order' => array(
                    'title' => 'order ID',
                    'width' => 'auto',
                    'type' => 'id'
                )
            );
            $helper = new HelperList();
            $helper->simple_header = true;
            $helper->identifier = 'product_id';
            $helper->show_toolbar = true;
            $helper->shopLinkType = '';
            $helper->title = $this->l('List of orders');
            $helper->token = Tools::getAdminTokenLite('AdminModules');
            $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
            return ($helper->generateList($result, $this->fields_list));
        }
    }

and I want to know if it is possible to call a function like this whenever an option in the dropdown is selected.

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...