Added more form helpers.

This commit is contained in:
Relintai 2021-11-16 16:41:47 +01:00
parent ff28b413d2
commit eee908912d
2 changed files with 60 additions and 0 deletions

View File

@ -502,6 +502,17 @@ HTMLTag *HTMLTag::method(const String &val) {
return this;
}
HTMLTag *HTMLTag::method_get() {
attrib("method", "get");
return this;
}
HTMLTag *HTMLTag::method_post() {
attrib("method", "post");
return this;
}
HTMLTag *HTMLTag::action(const String &val) {
attrib("action", val);
@ -2331,6 +2342,47 @@ HTMLBuilder *HTMLBuilder::cwbr() {
return this;
}
HTMLTag *HTMLBuilder::form_get() {
write_tag();
return tag.start("form")->method_get();
}
HTMLTag *HTMLBuilder::form_post() {
write_tag();
return tag.start("form")->method_post();
}
HTMLTag *HTMLBuilder::form_get(const String &action, const String &cls, const String &id) {
HTMLTag *t = form_get();
t->fora(action);
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
return t;
}
HTMLTag *HTMLBuilder::form_post(const String &action, const String &cls, const String &id) {
HTMLTag *t = form_post();
t->fora(action);
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
return t;
}
HTMLTag *HTMLBuilder::input_button() {
write_tag();

View File

@ -111,6 +111,9 @@ public:
HTMLTag *pattern(const String &val);
HTMLTag *method(const String &val);
HTMLTag *method_get();
HTMLTag *method_post();
HTMLTag *action(const String &val);
HTMLTag *type(const String &val);
HTMLTag *placeholder(const String &val);
@ -431,6 +434,11 @@ public:
HTMLBuilder *cvideo();
HTMLBuilder *cwbr();
HTMLTag *form_get();
HTMLTag *form_post();
HTMLTag *form_get(const String& action, const String& cls = "", const String& id = "");
HTMLTag *form_post(const String& action, const String& cls = "", const String& id = "");
HTMLTag *input_button();
HTMLTag *input_checkbox();
HTMLTag *input_color();