Added helper methods to the rest of the input types.

This commit is contained in:
Relintai 2021-11-16 13:55:58 +01:00
parent 9c53d521b4
commit 21bc5c4983
2 changed files with 248 additions and 11 deletions

View File

@ -125,6 +125,16 @@ HTMLTag *HTMLTag::required(const bool val) {
return this;
}
HTMLTag *HTMLTag::spellcheck(const bool val) {
if (val) {
attrib("spellcheck", "true");
} else {
attrib("spellcheck", "false");
}
return this;
}
HTMLTag *HTMLTag::max(const String &val) {
attrib("max", val);
@ -203,6 +213,12 @@ HTMLTag *HTMLTag::height(const String &val) {
return this;
}
HTMLTag *HTMLTag::pattern(const String &val) {
attrib("pattern", val);
return this;
}
HTMLTag *HTMLTag::method(const String &val) {
attrib("method", val);
@ -2498,7 +2514,7 @@ HTMLTag *HTMLBuilder::input_range(const String &name, const String &value, const
return t;
}
HTMLTag *HTMLBuilder::input_reset(const String& name, const String& value, const String& cls, const String& id) {
HTMLTag *HTMLBuilder::input_reset(const String &name, const String &value, const String &cls, const String &id) {
HTMLTag *t = input_reset();
t->name(name);
@ -2518,6 +2534,227 @@ HTMLTag *HTMLBuilder::input_reset(const String& name, const String& value, const
return t;
}
HTMLTag *HTMLBuilder::input_search(const String &name, const String &value, const String &placeholder, const String &cls, const String &id, const String &minlength, const String &maxlength, const String &size, const String &pattern) {
HTMLTag *t = input_search();
t->name(name);
if (value != "") {
t->value(value);
}
if (placeholder != "") {
t->placeholder(placeholder);
}
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
if (minlength != "") {
t->minlength(minlength);
}
if (maxlength != "") {
t->maxlength(maxlength);
}
if (size != "") {
t->size(size);
}
if (pattern != "") {
t->pattern(pattern);
}
return t;
}
HTMLTag *HTMLBuilder::input_submit(const String &value, const String &cls, const String &id) {
HTMLTag *t = input_submit();
t->value(value);
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
return t;
}
HTMLTag *HTMLBuilder::input_tel(const String &name, const String &value, const String &placeholder, const String &cls, const String &id, const String &minlength, const String &maxlength, const String &size, const String &pattern) {
HTMLTag *t = input_tel();
t->name(name);
if (value != "") {
t->value(value);
}
if (placeholder != "") {
t->placeholder(placeholder);
}
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
if (minlength != "") {
t->minlength(minlength);
}
if (maxlength != "") {
t->maxlength(maxlength);
}
if (size != "") {
t->size(size);
}
if (pattern != "") {
t->pattern(pattern);
}
return t;
}
HTMLTag *HTMLBuilder::input_text(const String &name, const String &value, const String &placeholder, const String &cls, const String &id, const String &minlength, const String &maxlength, const String &size) {
HTMLTag *t = input_text();
t->name(name);
if (value != "") {
t->value(value);
}
if (placeholder != "") {
t->placeholder(placeholder);
}
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
if (minlength != "") {
t->minlength(minlength);
}
if (maxlength != "") {
t->maxlength(maxlength);
}
if (size != "") {
t->size(size);
}
return t;
}
HTMLTag *HTMLBuilder::input_time(const String &name, const String &cls, const String &id, const String &vmin, const String &vmax, const String &vstep) {
HTMLTag *t = input_time();
t->name(name);
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
if (vmin != "") {
t->min(vmin);
}
if (vmax != "") {
t->max(vmax);
}
if (vstep != "") {
t->step(vstep);
}
return t;
}
HTMLTag *HTMLBuilder::input_url(const String &name, const String &value, const String &placeholder, const String &cls, const String &id, const String &minlength, const String &maxlength, const String &size) {
HTMLTag *t = input_url();
t->name(name);
if (value != "") {
t->value(value);
}
if (placeholder != "") {
t->placeholder(placeholder);
}
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
if (minlength != "") {
t->minlength(minlength);
}
if (maxlength != "") {
t->maxlength(maxlength);
}
if (size != "") {
t->size(size);
}
return t;
}
HTMLTag *HTMLBuilder::input_week(const String& name, const String& cls, const String& id, const String& vmin, const String& vmax) {
HTMLTag *t = input_week();
t->name(name);
if (cls != "") {
t->cls(cls);
}
if (id != "") {
t->id(id);
}
if (vmin != "") {
t->min(vmin);
}
if (vmax != "") {
t->max(vmax);
}
return t;
}
void HTMLBuilder::f() {
write_tag();
}

View File

@ -31,6 +31,7 @@ public:
HTMLTag *disabled(const bool val = true);
HTMLTag *multiple(const bool val = true);
HTMLTag *required(const bool val = true);
HTMLTag *spellcheck(const bool val);
HTMLTag *max(const String &val);
HTMLTag *min(const String &val);
@ -49,6 +50,8 @@ public:
HTMLTag *height(const int val);
HTMLTag *height(const String &val);
HTMLTag *pattern(const String &val);
HTMLTag *method(const String &val);
HTMLTag *action(const String &val);
HTMLTag *type(const String &val);
@ -411,16 +414,13 @@ public:
HTMLTag *input_radio(const String& name, const String& value = "", const String& cls = "", const String& id = "");
HTMLTag *input_range(const String& name, const String& value = "", const String& vmin = "", const String& vmax = "", const String& vstep = "", const String& cls = "", const String& id = "");
HTMLTag *input_reset(const String& name, const String& value = "", const String& cls = "", const String& id = "");
/*
HTMLTag *input_search();
HTMLTag *input_submit();
HTMLTag *input_tel();
HTMLTag *input_text();
HTMLTag *input_time();
HTMLTag *input_url();
HTMLTag *input_week();
*/
HTMLTag *input_search(const String& name, const String& value = "", const String& placeholder = "", const String& cls = "", const String& id = "", const String& minlength = "", const String& maxlength = "", const String& size = "", const String& pattern = "");
HTMLTag *input_submit(const String& value, const String& cls = "", const String& id = "");
HTMLTag *input_tel(const String& name, const String& value = "", const String& placeholder = "", const String& cls = "", const String& id = "", const String& minlength = "", const String& maxlength = "", const String& size = "", const String& pattern = "");
HTMLTag *input_text(const String& name, const String& value = "", const String& placeholder = "", const String& cls = "", const String& id = "", const String& minlength = "", const String& maxlength = "", const String& size = "");
HTMLTag *input_time(const String& name, const String& cls = "", const String& id = "", const String& vmin = "", const String& vmax = "", const String& vstep = "");
HTMLTag *input_url(const String& name, const String& value = "", const String& placeholder = "", const String& cls = "", const String& id = "", const String& minlength = "", const String& maxlength = "", const String& size = "");
HTMLTag *input_week(const String& name, const String& cls = "", const String& id = "", const String& vmin = "", const String& vmax = "");
void f();