From: Andrea Zagli Date: Fri, 10 May 2024 10:15:21 +0000 (+0200) Subject: Added text property for FieldCheck. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=c331c60e0e2d8c040cf69e058b90a72b1b71762d;p=rust%2Fzakform Added text property for FieldCheck. --- diff --git a/src/fields.rs b/src/fields.rs index 4eee14a..841f2ad 100644 --- a/src/fields.rs +++ b/src/fields.rs @@ -914,6 +914,7 @@ _ => {}, #[derive(Default)] pub struct FieldCheck { field: Field, + text: String, } impl TField for FieldCheck { @@ -1040,6 +1041,7 @@ impl TField for FieldCheck { context.insert("help", &self.field.help); context.insert("class", &self.field.class); context.insert("value", &self.field.value); + context.insert("text", &self.text); s.push_str(self.field.tmpl.render("field", &context).unwrap().as_str()); s @@ -1064,17 +1066,28 @@ impl FieldCheck { f.field.to_save = true; f.field.to_render = true; - match f.field.tmpl.add_raw_template("field", r#"
+ match f.field.tmpl.add_raw_template("field", r#"{% if label %}
+ {% endif %} +
- {% if label %}{% endif %} + {% if text %}{% endif %} {% if help %}
{{ help }}
{% endif %} -
"#) { +
+ {% if label %}
{% endif %}"#) { Err(e) => { println!("{:?}", e) }, _ => {}, }; f } + + pub fn get_text(&self) -> String { + String::from(&self.text) + } + + pub fn set_text(&mut self, text: &str) { + self.text = String::from(text); + } } #[derive(Default)]