From c331c60e0e2d8c040cf69e058b90a72b1b71762d Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Fri, 10 May 2024 12:15:21 +0200 Subject: [PATCH] Added text property for FieldCheck. --- src/fields.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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)] -- 2.49.0