我想从数据库中提取复选框值并在表单中显示,当点击提交时,新值应该在Prestashop中更新。从数据库中获取复选框值并在表单中显示并在prestashop中提交
我已经完成了foreach
与提取的数据库值,但只有一个值显示。
我的代码是:
protected function getConfigForm()
{
$sql = 'SELECT id_order_state,name FROM '._DB_PREFIX_.'order_state_lang';
$results = Db::getInstance()->ExecuteS($sql);
foreach ($results as $row) {
return array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'checkbox',
'label' => $this->l('Select Required Status'),
'required' => true,
'values' => array(
'query' => array(
array(
'id' => 'AllFields',
'name' => $this->l('All Fields'),
'val' => 'All',
),
array(
'id' => 'OrderID',
'name' => $this->l($row['name']),
'val' => $row['id_order_state'],
'required' => true,
),
),
'id' => 'id',
'name' => 'name'
),
),
),
// array(
// 'type' => 'text',
// 'name' => 'EXPORTORDERS_LOCATION',
// 'label' => $this->l('Export Location'),
// ),
'submit' => array(
'title' => $this->l('Save'),
),
),
);
}
}
请问您的查询返回多行多..?如果是这样,你在循环的第一次迭代期间将返回。如果没有,为什么你需要循环? – BizzyBob
,因为在我的数据库中有很多状态存储,我想显示在配置页面中的所有状态为复选框,所以我用foreach显示所有在该页面,但只有一个显示 –
我在说的是,你只是处理你的结果的第一行,因为你正在'foreach'循环内执行'return'。 – BizzyBob