pub struct TextInputConfig {
pub max_length: Option<usize>,
pub min_length: Option<usize>,
pub list: Option<String>,
pub place_holder: Option<String>,
pub pattern: Option<String>,
pub size: Option<u64>,
pub required: bool,
pub read_only: bool,
pub spell_check: bool,
}Expand description
Represents an <input type="text"> configs.
max_length: The input’s max length. If the value is None, this parameter is ignored.min_length: The input’s min length. If the value is None, this parameter is ignored.list: The input’s associated<datalist>id. If the value is None, this parameter is ignored.place_holder: The helper text displayed in the input. If the value is None, this parameter is ignored.pattern: The regex pattern for the input validation. If the value is None, this parameter is ignored.size: The number of characters displayed in the input. If the value is None, this parameter is ignored.required: Indicates if the input is required.read_only: Indicates if the input is read only.spell_check: Indicates if spell checking is activated.
Fields§
§max_length: Option<usize>§min_length: Option<usize>§list: Option<String>§place_holder: Option<String>§pattern: Option<String>§size: Option<u64>§required: bool§read_only: bool§spell_check: boolImplementations§
Source§impl TextInputConfig
impl TextInputConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new text input configs.
Examples found in repository?
86 fn as_form_field(&self) -> Option<Element> {
87 let model_name_field = create_label_text_field(
88 InputFieldConfig::new(
89 "model-name".to_string(),
90 "model-name".to_string(),
91 "Model name".to_string(),
92 ),
93 TextInputConfig::new().with_place_holder("Enter model name".to_string()),
94 Some(self.model_name.clone()),
95 );
96 let brand_field = self.brand.as_form_field().unwrap();
97 let vehicul_fieldset = wrap_fields_in_fieldset(
98 vec![model_name_field, brand_field],
99 "Vehicule model".to_string(),
100 HtmlElementConfig::new_empty(),
101 HtmlElementConfig::new_empty(),
102 );
103
104 let motor_fieldset = wrap_fields_in_fieldset(
105 vec![self.motor.as_form_field().unwrap()],
106 "Motor".to_string(),
107 HtmlElementConfig::new_empty(),
108 HtmlElementConfig::new_empty(),
109 );
110
111 let color_input = color_input::create_labeled_color_input(
112 InputFieldConfig::new(
113 "color".to_string(),
114 "color".to_string(),
115 "color".to_string(),
116 ),
117 Some(self.color.clone()),
118 );
119
120 let date_input = date_input::create_date_input_with_label(
121 InputFieldConfig::new(
122 "bought_the".to_string(),
123 "bought_the".to_string(),
124 "Bought the".to_string(),
125 ),
126 DateInputConfig::new(false),
127 Some(self.bought_the.clone()),
128 );
129 let dealership = self.dealership.as_form_field().unwrap();
130 let hidden = create_hidden_input(
131 InputFieldConfig::new(
132 "hidden-id".to_string(),
133 "hidden-id".to_string(),
134 "".to_string(),
135 ),
136 Some(self.hidden_id.clone()),
137 );
138
139 let power = create_labeled_number_input(
140 InputFieldConfig::new(
141 "hidden-id".to_string(),
142 "hidden-id".to_string(),
143 "".to_string(),
144 ),
145 NumberInputConfigs::new(),
146 Some(self.power),
147 );
148
149 let size = create_labeled_range_input(
150 InputFieldConfig::new(
151 "size".to_string(),
152 "size".to_string(),
153 "Size filter".to_string(),
154 ),
155 RangeInputConfigs::new(3.0, 6.0),
156 Some(self.length),
157 );
158
159 let start = create_labeled_time_input(
160 InputFieldConfig::new(
161 "reset".to_string(),
162 "reset".to_string(),
163 "Reset form".to_string(),
164 ),
165 TimeInputConfigs::new(),
166 Some(self.last_start_time.clone()),
167 );
168
169 let benchmark = create_labeled_week_input(
170 InputFieldConfig::new(
171 "bencmark".to_string(),
172 "bencmark".to_string(),
173 "Benchmark week".to_string(),
174 ),
175 WeekInputConfigs::new(),
176 Some(self.benchmark_week.clone()),
177 );
178
179 let description = create_labeled_text_area(
180 InputFieldConfig::new(
181 "description".to_string(),
182 "description".to_string(),
183 "Description".to_string(),
184 ),
185 TextAreaInputConfigs::new(),
186 Some(self.description.clone()),
187 );
188
189 let tires = self.tyres.as_form_field().unwrap();
190
191 let reset = create_labeled_reset_input(
192 InputFieldConfig::new(
193 "reset".to_string(),
194 "reset".to_string(),
195 "Reset form".to_string(),
196 ),
197 Some("reset".to_string()),
198 );
199
200 let submit = create_submit_input(
201 InputFieldConfig::new(
202 "submit".to_string(),
203 "submit".to_string(),
204 "submit".to_string(),
205 ),
206 SubmitInputConfigs::new(),
207 );
208
209 create_form(
210 vec![
211 vehicul_fieldset,
212 color_input,
213 motor_fieldset,
214 date_input,
215 dealership,
216 hidden,
217 power,
218 size,
219 benchmark,
220 description,
221 tires,
222 start,
223 reset,
224 submit,
225 ],
226 FormConfig::new().with_method("POST".to_string()),
227 HtmlElementConfig::new_empty(),
228 )
229 }Sourcepub fn with_max_length(self, max_length: usize) -> Self
pub fn with_max_length(self, max_length: usize) -> Self
Sets the field’s max length attribute.
max_length: The new field’s max length.
Sourcepub fn without_max_length(self) -> Self
pub fn without_max_length(self) -> Self
Clears the field’s max length attribute.
Sourcepub fn with_min_length(self, min_length: usize) -> Self
pub fn with_min_length(self, min_length: usize) -> Self
Sets the field’s min length attribute.
min_length: The new field’s min length.
Sourcepub fn without_min_length(self) -> Self
pub fn without_min_length(self) -> Self
Clears the field’s min length attribute.
Sourcepub fn with_list(self, list: String) -> Self
pub fn with_list(self, list: String) -> Self
Sets the field’s list attribute.
list: The new field’s list.
Sourcepub fn without_list(self) -> Self
pub fn without_list(self) -> Self
Clears the field’s list attribute.
Sourcepub fn with_place_holder(self, place_holder: String) -> Self
pub fn with_place_holder(self, place_holder: String) -> Self
Sets the field’s place holder attribute.
place_holder: The new field’s place holder.
Examples found in repository?
86 fn as_form_field(&self) -> Option<Element> {
87 let model_name_field = create_label_text_field(
88 InputFieldConfig::new(
89 "model-name".to_string(),
90 "model-name".to_string(),
91 "Model name".to_string(),
92 ),
93 TextInputConfig::new().with_place_holder("Enter model name".to_string()),
94 Some(self.model_name.clone()),
95 );
96 let brand_field = self.brand.as_form_field().unwrap();
97 let vehicul_fieldset = wrap_fields_in_fieldset(
98 vec![model_name_field, brand_field],
99 "Vehicule model".to_string(),
100 HtmlElementConfig::new_empty(),
101 HtmlElementConfig::new_empty(),
102 );
103
104 let motor_fieldset = wrap_fields_in_fieldset(
105 vec![self.motor.as_form_field().unwrap()],
106 "Motor".to_string(),
107 HtmlElementConfig::new_empty(),
108 HtmlElementConfig::new_empty(),
109 );
110
111 let color_input = color_input::create_labeled_color_input(
112 InputFieldConfig::new(
113 "color".to_string(),
114 "color".to_string(),
115 "color".to_string(),
116 ),
117 Some(self.color.clone()),
118 );
119
120 let date_input = date_input::create_date_input_with_label(
121 InputFieldConfig::new(
122 "bought_the".to_string(),
123 "bought_the".to_string(),
124 "Bought the".to_string(),
125 ),
126 DateInputConfig::new(false),
127 Some(self.bought_the.clone()),
128 );
129 let dealership = self.dealership.as_form_field().unwrap();
130 let hidden = create_hidden_input(
131 InputFieldConfig::new(
132 "hidden-id".to_string(),
133 "hidden-id".to_string(),
134 "".to_string(),
135 ),
136 Some(self.hidden_id.clone()),
137 );
138
139 let power = create_labeled_number_input(
140 InputFieldConfig::new(
141 "hidden-id".to_string(),
142 "hidden-id".to_string(),
143 "".to_string(),
144 ),
145 NumberInputConfigs::new(),
146 Some(self.power),
147 );
148
149 let size = create_labeled_range_input(
150 InputFieldConfig::new(
151 "size".to_string(),
152 "size".to_string(),
153 "Size filter".to_string(),
154 ),
155 RangeInputConfigs::new(3.0, 6.0),
156 Some(self.length),
157 );
158
159 let start = create_labeled_time_input(
160 InputFieldConfig::new(
161 "reset".to_string(),
162 "reset".to_string(),
163 "Reset form".to_string(),
164 ),
165 TimeInputConfigs::new(),
166 Some(self.last_start_time.clone()),
167 );
168
169 let benchmark = create_labeled_week_input(
170 InputFieldConfig::new(
171 "bencmark".to_string(),
172 "bencmark".to_string(),
173 "Benchmark week".to_string(),
174 ),
175 WeekInputConfigs::new(),
176 Some(self.benchmark_week.clone()),
177 );
178
179 let description = create_labeled_text_area(
180 InputFieldConfig::new(
181 "description".to_string(),
182 "description".to_string(),
183 "Description".to_string(),
184 ),
185 TextAreaInputConfigs::new(),
186 Some(self.description.clone()),
187 );
188
189 let tires = self.tyres.as_form_field().unwrap();
190
191 let reset = create_labeled_reset_input(
192 InputFieldConfig::new(
193 "reset".to_string(),
194 "reset".to_string(),
195 "Reset form".to_string(),
196 ),
197 Some("reset".to_string()),
198 );
199
200 let submit = create_submit_input(
201 InputFieldConfig::new(
202 "submit".to_string(),
203 "submit".to_string(),
204 "submit".to_string(),
205 ),
206 SubmitInputConfigs::new(),
207 );
208
209 create_form(
210 vec![
211 vehicul_fieldset,
212 color_input,
213 motor_fieldset,
214 date_input,
215 dealership,
216 hidden,
217 power,
218 size,
219 benchmark,
220 description,
221 tires,
222 start,
223 reset,
224 submit,
225 ],
226 FormConfig::new().with_method("POST".to_string()),
227 HtmlElementConfig::new_empty(),
228 )
229 }Sourcepub fn without_place_holder(self) -> Self
pub fn without_place_holder(self) -> Self
Clears the field’s place holder attribute.
Sourcepub fn with_pattern(self, pattern: String) -> Self
pub fn with_pattern(self, pattern: String) -> Self
Sets the field’s pattern attribute.
pattern: The new field’s pattern.
Sourcepub fn without_pattern(self) -> Self
pub fn without_pattern(self) -> Self
Clears the field’s pattern attribute.
Sourcepub fn with_size(self, size: u64) -> Self
pub fn with_size(self, size: u64) -> Self
Sets the field’s size attribute.
size: The new field’s size.
Sourcepub fn without_size(self) -> Self
pub fn without_size(self) -> Self
Clears the field’s size attribute.
Sourcepub fn set_required(self) -> Self
pub fn set_required(self) -> Self
Sets the field’s required attribute at true.
Sourcepub fn set_non_required(self) -> Self
pub fn set_non_required(self) -> Self
Sets the field’s required attribute at false.
Sourcepub fn set_read_only(self) -> Self
pub fn set_read_only(self) -> Self
Sets the field’s read only attribute at true.
Sourcepub fn set_non_read_only(self) -> Self
pub fn set_non_read_only(self) -> Self
Sets the field’s read only attribute at false.
Sourcepub fn set_spell_check(self) -> Self
pub fn set_spell_check(self) -> Self
Sets the field’s spell check attribute at true.
Sourcepub fn set_non_spell_check(self) -> Self
pub fn set_non_spell_check(self) -> Self
Sets the field’s spell check attribute at false.