The code below does not seem to filter the site names by customer_id. It still shows all sites names, i am not sure what i am doing wrong here.
// CUSTOMER SITE
$col = array();
$col[“title”] = “Site Name”;
$col[“name”] = “site_name”;
$col[“dbname”] = “store.customer_site_id”;
$str = $g->get_dropdown_values(“SELECT *, site_name as v, customer_site_id as k FROM tbl_customer_sites”);
$col[“width”] = “55”;
$col[“hidden”] = true;
$col[“editable”] = true;
$col[“stype”] = “select”;
$col[“edittype”] = “select”;
$col[“show”] = array(“list”=>true, “add”=>true, “edit”=>true, “view”=>false, “bulkedit”=>false);
$col[“editoptions”] = array(“value” => “:;” . $str);
$col[“editoptions”][“dataInit”][“sql”] = “SELECT customer_site_id AS k, site_name AS v FROM tbl_customer_sites WHERE sites_fk_customer_id IN ({customer_id})”;
$col[“export”] = false;
$col[“editrules”] = array(“required”=>true);
$cols[] = $col;
Thanks in advanced.
Tim
Please share complete code for review including select command query.
If you are using OR condition in query, make sure you enclose it in ( ) so it may not combine with other AND conditions.
https://gist.github.com/tmoore88/a5268f5e3429334d177a19af371b2574
The code above is the complete code
Thanks,
Tim
Replied on your direct email.
…
I was little occupied in other cases so this ticket was missed.
After reviewing your code, I can see there is no table ‘store’ in your select_command so most like this query is failing due to this.
$col[“dbname”] = “store.customer_site_id”;
Try changing it to:
$col[“dbname”] = “customer_site_id”;
You can also set:
$g->debug_search = true;
And this will show the complete select query in debug box for review.