ZakFormElement *v1;
ZakFormElement *v2;
+
+ ZakFormElement *message;
};
G_DEFINE_TYPE_WITH_PRIVATE (ZakFormValidatorCompare, zak_form_validator_compare, ZAK_FORM_TYPE_VALIDATOR)
priv->v1 = NULL;
priv->v2 = NULL;
+ priv->message = NULL;
}
/**
zak_form_validator_compare_set_element2 ((ZakFormValidatorCompare *)validator, (ZakFormForm *)form, prop);
g_free (prop);
+ prop = (gchar *)xmlGetProp (xnode, (const xmlChar *)"element_message");
+ zak_form_validator_compare_set_element_message ((ZakFormValidatorCompare *)validator, (ZakFormForm *)form, prop);
+ g_free (prop);
+
return TRUE;
}
}
}
+/**
+ * zak_form_validator_compare_set_element_message:
+ * @validator:
+ * @element:
+ *
+ * Sets the validator element with error message.
+ */
+void
+zak_form_validator_compare_set_element_message (ZakFormValidatorCompare *validator, ZakFormForm *form, const gchar *element)
+{
+ ZakFormValidatorComparePrivate *priv = zak_form_validator_compare_get_instance_private (validator);
+
+ priv->message = zak_form_form_get_element_by_id (form, element);
+ if (!ZAK_FORM_IS_ELEMENT (priv->message))
+ {
+ g_warning ("Validator compare: element «%s» isn't a ZakFormElement.", element);
+ }
+}
+
+/**
+ * zak_form_validator_compare_get_element_message:
+ * @validator:
+ *
+ * Returns: the validator element name with error message.
+ */
+const gchar
+*zak_form_validator_compare_get_element_message (ZakFormValidatorCompare *validator)
+{
+ ZakFormValidatorComparePrivate *priv = zak_form_validator_compare_get_instance_private (validator);
+
+ if (ZAK_FORM_IS_ELEMENT (priv->message))
+ {
+ return zak_form_element_get_name (priv->message);
+ }
+ else
+ {
+ return "";
+ }
+}
+
/* PRIVATE */
static void
zak_form_validator_compare_set_property (GObject *object,
zak_form_get_compare_type_stringify (priv->type),
zak_form_element_get_long_name (priv->v2));
zak_form_validator_set_message (validator, msg);
+
+ if (priv->message != NULL)
+ {
+ zak_form_element_add_message (priv->message, msg);
+ }
+
g_free (msg);
}
}
xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_get_element1 (validator_compare));
xmlSetProp (xnode, (const xmlChar *)"element2", (const xmlChar *)zak_form_validator_compare_get_element2 (validator_compare));
+
+ xmlSetProp (xnode, (const xmlChar *)"element_message", (const xmlChar *)zak_form_validator_compare_get_element_message (validator_compare));
}