AntadisConfigurator : Error when field as the same value

This commit is contained in:
Michael RICOIS 2017-10-20 11:22:58 +02:00
parent fcde7e1d05
commit 1cd891bcd3

View File

@ -362,12 +362,22 @@ class ConfiguratorStorage extends ObjectModel
foreach($result as $item) {
if ($item['required'] == 1) {
if (!array_key_exists($item['id_configurator_opt_group'], $optIds)) {
$errors[] = Tools::displayError('Error : field '.$item['name'].' has no value');
$errors[] = sprintf(Tools::displayError('Error : field %s has no value'), $item['name']);
}
else {
$value = $optIds[$item['id_configurator_opt_group']];
if (empty($value)) {
$errors[] = Tools::displayError('Error : field '.$item['name'].' has no value');
$errors[] = sprintf(Tools::displayError('Error : field %s has no value'), $item['name']);
}
}
if ($item['type'] == 'text') {
$sql = "SELECT col.name
FROM ps_configurator_opt_lang col, ps_configurator_opt co
WHERE co.id_configurator_opt = col.id_configurator_opt
AND co.id_configurator_opt_group = ".$item['id_configurator_opt_group'];
$value = Db::getInstance()->getValue($sql);
if ($optIds[$item['id_configurator_opt_group']] === $value) {
$errors[] = sprintf(Tools::displayError('Error : field %s has no value'), $item['name']);
}
}
}