Hi,
I am working with my simple module and i have next problem, that i can't understand.
In module config page i have to forms. First display something from db in inputs and works great. When i change something in input and not click save (submit this form), change wouldn't be save in db, when i click save all inputs are update, great. But in second form, that i use to add new rows in db is problem.
When i am in new tab in this config page and realod my page nothing happens. But when i only once type something to inputs second form, click this submit, it looks like vars are not cleared. Now if i reload page 10 times i will have 10 new field, although i don't click submit.
code from get Content function:
$new_field_title = null;
$new_field_value = null;
if (Tools::isSubmit('add_new_field')){
$new_field_title = strval(Tools::getValue('new-field-title'));
$new_field_value = strval(Tools::getValue('new-field-value'));
if( !$new_field_value
|| empty($new_field_value)
|| !Validate::isGenericName($new_field_value)
||!$new_field_title
|| empty($new_field_title)
|| !Validate::isGenericName($new_field_title) ){
}
else{
$sql = "INSERT INTO "._DB_PREFIX_."fields (title, value) VALUES ('".$new_field_title."','".$new_field_value."')";
Db::getInstance()->Execute($sql);
}
}