if (!zak_form_element_get_editable (ZAK_FORM_ELEMENT (element)))
{
- g_hash_table_insert (priv->ht_attrs, (gpointer)"readonly", (gpointer)"readonly");
+ zak_form_cgi_form_element_set_attr (element, "readonly", "readonly");
}
g_string_append (str, ZAK_FORM_CGI_FORM_ELEMENT_GET_CLASS (element)->render (element));
return ret;
}
+gchar
+*zak_form_cgi_form_element_get_attr (ZakFormCgiFormElement *element, const gchar *attr)
+{
+ ZakFormCgiFormElementPrivate *priv;
+
+ priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ if (priv->ht_attrs == NULL)
+ {
+ return NULL;
+ }
+ else
+ {
+ return g_hash_table_lookup (priv->ht_attrs, attr);
+ }
+}
+
+void
+zak_form_cgi_form_element_set_attr (ZakFormCgiFormElement *element, const gchar *attr, const gchar *value)
+{
+ ZakFormCgiFormElementPrivate *priv;
+
+ priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ if (priv->ht_attrs == NULL)
+ {
+ priv->ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+
+ if (value == NULL)
+ {
+ g_hash_table_remove (priv->ht_attrs, attr);
+ }
+ else
+ {
+ g_hash_table_insert (priv->ht_attrs, g_strdup (attr), g_strdup (value));
+ }
+}
+
gboolean
zak_form_cgi_form_element_has_class (ZakFormCgiFormElement *element, const gchar *class)
{
if (g_hash_table_lookup (priv->ht_attrs, "name") == NULL)
{
- g_hash_table_insert (priv->ht_attrs, "name", g_strdup (id));
+ zak_form_cgi_form_element_set_attr (element, "name", id);
}
zak_form_element_set_name (ZAK_FORM_ELEMENT (element), g_hash_table_lookup (priv->ht_attrs, "name"));
gchar *zak_form_cgi_form_element_render (ZakFormCgiFormElement *element);
gchar *zak_form_cgi_form_element_render_label (ZakFormCgiFormElement *element);
+gchar *zak_form_cgi_form_element_get_attr (ZakFormCgiFormElement *element, const gchar *attr);
+void zak_form_cgi_form_element_set_attr (ZakFormCgiFormElement *element, const gchar *attr, const gchar *value);
+
gboolean zak_form_cgi_form_element_has_class (ZakFormCgiFormElement *element, const gchar *class);
void zak_form_cgi_form_element_add_class (ZakFormCgiFormElement *element, const gchar *class);
void zak_form_cgi_form_element_remove_class (ZakFormCgiFormElement *element, const gchar *class);