green_barrel/fields/
bool.rs1use core::fmt::Debug;
4use serde::{Deserialize, Serialize};
5
6#[derive(Serialize, Deserialize, Clone, Debug)]
7pub struct BoolField {
8 pub id: String,
11 pub label: String,
13 pub field_type: String,
15 pub input_type: String,
17 pub name: String,
19 pub value: Option<bool>,
21 pub default: Option<bool>,
23 pub placeholder: String,
25 pub disabled: bool,
27 pub readonly: bool,
29 pub is_hide: bool,
31 pub other_attrs: String,
33 pub css_classes: String,
35 pub hint: String,
37 pub warning: String,
39 pub errors: Vec<String>,
41 pub group: u32,
44}
45
46impl Default for BoolField {
47 fn default() -> Self {
48 Self {
49 id: String::new(),
50 label: String::new(),
51 field_type: String::from("BoolField"),
52 input_type: String::from("checkbox"),
53 name: String::new(),
54 value: None,
55 default: Some(false),
56 placeholder: String::new(),
57 disabled: false,
58 readonly: false,
59 is_hide: false,
60 other_attrs: String::new(),
61 css_classes: String::new(),
62 hint: String::new(),
63 warning: String::new(),
64 errors: Vec::new(),
65 group: 13,
66 }
67 }
68}
69
70impl BoolField {
71 pub fn get(&self) -> Option<bool> {
73 self.value
74 }
75 pub fn set(&mut self, value: bool) {
77 self.value = Some(value);
78 }
79}