fi.set_value(map.get(fi.name().as_str()).unwrap().as_str());
fi.add_filter(filters::filter_uppercase);
fi.filter();
+ fi.set_template(r#"{% if label %}<div class="mb-3" style="background-color: #FF0000;">
+ <label for="{{ name }}" class="form-label">{{ label }}</label>{% endif %}
+ <input type="text" class="form-control{% if help %} is-invalid{% endif %}" name="{{ name }}" id="{{ name }}" {% if value %} value="{{ value }}" {% endif %} {% if disabled %} readonly {% endif %} {% if maxlen > 0 %}maxlength="{{ maxlen }}"{% endif %} {% if invisible %}style="display: none;"{% endif %}/>
+ {% if help %}<div id="helpBox_{{ name }}_" class="invalid-feedback">{{ help }}</div>{% endif %}
+ {% if label %}</div>{% endif %}"#);
f.add_field(fi);
let mut fi = zakform::Field::new(zakform::FType::TextArea, "notes");
let mut fi = zakform::Field::new(zakform::FType::Text, "name");
fi.set_label("Name");
+ fi.set_template(r#"{% if label %}<div class="mb-3" style="background-color: #FF0000;">
+ <label for="{{ name }}" class="form-label">{{ label }}</label>{% endif %}
+ <input type="text" class="form-control{% if help %} is-invalid{% endif %}" name="{{ name }}" id="{{ name }}" {% if value %} value="{{ value }}" {% endif %} {% if disabled %} readonly {% endif %} {% if maxlen > 0 %}maxlength="{{ maxlen }}"{% endif %} {% if invisible %}style="display: none;"{% endif %}/>
+ {% if help %}<div id="helpBox_{{ name }}_" class="invalid-feedback">{{ help }}</div>{% endif %}
+ {% if label %}</div>{% endif %}"#);
f.add_field(fi);
let mut fi = zakform::Field::new(zakform::FType::TextArea, "notes");
self.options.push(option);
}
+ pub fn set_template(&mut self, template: &str) {
+ self.tmpl.add_raw_template("field", template);
+ }
+
pub fn add_filter(&mut self, filter: filters::Filter) {
self.filters.push(filter);
}