*********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php'); $json = new PommoJSON(); SmartyValidate::connect($smarty); if (SmartyValidate::is_valid($_POST)) { // __ FORM IS VALID // TODO -> Which below logic is better? the computed diff, or send all fields for update? /* // make a difference between updated & original field $update = array_diff_assoc(PommoField::makeDB($_POST),$field); // restore the ID $update['id'] = $field['id']; */ // let MySQL do the difference processing $update = PommoField::makeDB($_POST); if (!PommoField::update($update)) { $json->fail('error updating field'); } $json->add('callbackFunction', 'updateField'); $json->add('callbackParams', $update); $json->success(Pommo::_T('Settings updated.')); } else { // __ FORM NOT VALID $json->add('fieldErrors', $smarty->getInvalidFields()); $json->fail(Pommo::_T('Please review and correct errors with your submission.')); } } $f_text = sprintf(Pommo::_T('%s - Any value will be accepted for text fields. They are useful for collecting names, addresses, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Text') . ')</strong>'); $f_check = sprintf(Pommo::_T('%s - Checkboxes can be toggled ON or OFF. They are useful for opt-ins and agreements.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Checkbox') . ')</strong>'); $f_num = sprintf(Pommo::_T('%s - Only Numeric values will be accepted for number fields.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Number') . ')</strong>'); $f_date = sprintf(Pommo::_T('%s - Only calendar values will be accepted for this field. A date selector (calendar popup) will appear next to the field to aid the subscriber in selecting a date.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Date') . ')</strong>');