public $nobuttons = false;
/**
+ * List of update errors.
+ *
+ * @var array
+ */
+ protected $_errors = array();
+
+ /**
* Constructor.
*
* @param Horde_Variables $vars Form variables.
if (isset($enum[$this->vars->$pref])) {
$updated |= $save->setValue($pref, $this->vars->$pref);
} else {
- $notification->push(Horde_Core_Translation::t("An illegal value was specified."), 'horde.error');
+ $this->_errors[$pref] = Horde_Core_Translation::t("An illegal value was specified.");
}
break;
if (isset($enum[$val])) {
$set[] = $val;
} else {
- $notification->push(Horde_Core_Translation::t("An illegal value was specified."), 'horde.error');
+ $this->_errors[$pref] = Horde_Core_Translation::t("An illegal value was specified.");
break 2;
}
}
case 'number':
$num = $this->vars->$pref;
if ((string)(double)$num !== $num) {
- $notification->push(Horde_Core_Translation::t("This value must be a number."), 'horde.error');
+ $this->_errors[$pref] = Horde_Core_Translation::t("This value must be a number.");
} elseif (empty($num)) {
- $notification->push(Horde_Core_Translation::t("This number must be non-zero."), 'horde.error');
+ $this->_errors[$pref] = Horde_Core_Translation::t("This value must be non-zero.");
} else {
$updated |= $save->setValue($pref, $num);
}
}
}
+ if (count($this->_errors)) {
+ $notification->push(Horde_Core_Translation::t("There were errors encountered while updating your preferences."), 'horde.error');
+ }
+
if ($updated) {
if ($save instanceof Horde_Prefs_Identity) {
// Throws Exception caught in _identitiesUpdate().
}
$t = clone $base;
+
+ if (isset($this->_errors[$pref])) {
+ echo $t->fetch(HORDE_TEMPLATES . '/prefs/error_start.html');
+ }
+
if (isset($this->prefs[$pref]['desc'])) {
$t->set('desc', Horde::label($pref, $this->prefs[$pref]['desc']));
}
}
echo $t->fetch(HORDE_TEMPLATES . '/prefs/' . $type . '.html');
+
+ if (isset($this->_errors[$pref])) {
+ $t->set('error', htmlspecialchars($this->_errors[$pref]));
+ echo $t->fetch(HORDE_TEMPLATES . '/prefs/error_end.html');
+ }
}
$t = clone $base;