From: Andrea Zagli Date: Sun, 24 Sep 2023 10:38:58 +0000 (+0200) Subject: Added field text placeholder attribute. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=30f3a081300cf69b370873723b8bf0c8e87505ff;p=rust%2Fzakform Added field text placeholder attribute. --- diff --git a/src/fields.rs b/src/fields.rs index 8ead055..be1f9ca 100644 --- a/src/fields.rs +++ b/src/fields.rs @@ -79,6 +79,7 @@ pub trait TField { pub struct FieldText { field: Field, maxlen: i32, + placeholder: String, } impl TField for FieldText { @@ -219,7 +220,7 @@ impl FieldText { match f.field.tmpl.add_raw_template("field", r#"{% if label %}
{% endif %} - 0 %}maxlength="{{ maxlen }}"{% endif %} {% if invisible %}style="display: none;"{% endif %}/> + 0 %}maxlength="{{ maxlen }}"{% endif %} {% if invisible %}style="display: none;"{% endif %} {% if placeholder %}placeholder="{{ placeholder }}"{% endif %}/> {% if help %}
{{ help }}
{% endif %} {% if label %}
{% endif %}"#) { Err(e) => { println!("{:?}", e) }, @@ -236,6 +237,14 @@ _ => {}, pub fn get_maxlen(&self) -> i32 { self.maxlen } + + pub fn set_placeholder(&mut self, placeholder: &String) { + self.placeholder = String::from(placeholder); + } + + pub fn get_placeholder(&self) -> String { + String::from(&self.placeholder) + } } #[derive(Default)] @@ -386,7 +395,7 @@ impl FieldTextArea { match f.field.tmpl.add_raw_template("field", r#"{% if label %}
{% endif %} - {% if help %}
{{ help }}
{% endif %} {% if label %}
{% endif %}"#) { @@ -566,7 +575,7 @@ impl FieldRadio {
{% endif %} {% for o in options %}
- +
{% endfor %} @@ -577,7 +586,7 @@ _ => {}, }; match f.field.tmpl.add_raw_template("field_single", r#"
- +
"#) { Err(e) => { println!("{:?}", e) }, @@ -773,7 +782,7 @@ impl FieldSelect { match f.field.tmpl.add_raw_template("field", r#"{% if label %}

{% endif %} - {% for o in options %} {% endfor %} @@ -945,7 +954,7 @@ impl FieldCheck { f.field.to_render = true; match f.field.tmpl.add_raw_template("field", r#"
- + {% if label %}{% endif %} {% if help %}
{{ help }}
{% endif %}
"#) { @@ -1097,7 +1106,7 @@ impl FieldButton { f.field.label = String::from(name); f.field.to_render = true; - match f.field.tmpl.add_raw_template("field", r#""#) { Err(e) => { println!("{:?}", e) }, _ => {},