Struct TextInputConfig

Source
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: bool

Implementations§

Source§

impl TextInputConfig

Source

pub fn new() -> Self

Creates a new text input configs.

Examples found in repository?
examples/forms.rs (line 93)
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    }
Source

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.
Source

pub fn without_max_length(self) -> Self

Clears the field’s max length attribute.

Source

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.
Source

pub fn without_min_length(self) -> Self

Clears the field’s min length attribute.

Source

pub fn with_list(self, list: String) -> Self

Sets the field’s list attribute.

  • list : The new field’s list.
Source

pub fn without_list(self) -> Self

Clears the field’s list attribute.

Source

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?
examples/forms.rs (line 93)
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    }
Source

pub fn without_place_holder(self) -> Self

Clears the field’s place holder attribute.

Source

pub fn with_pattern(self, pattern: String) -> Self

Sets the field’s pattern attribute.

  • pattern : The new field’s pattern.
Source

pub fn without_pattern(self) -> Self

Clears the field’s pattern attribute.

Source

pub fn with_size(self, size: u64) -> Self

Sets the field’s size attribute.

  • size : The new field’s size.
Source

pub fn without_size(self) -> Self

Clears the field’s size attribute.

Source

pub fn set_required(self) -> Self

Sets the field’s required attribute at true.

Source

pub fn set_non_required(self) -> Self

Sets the field’s required attribute at false.

Source

pub fn set_read_only(self) -> Self

Sets the field’s read only attribute at true.

Source

pub fn set_non_read_only(self) -> Self

Sets the field’s read only attribute at false.

Source

pub fn set_spell_check(self) -> Self

Sets the field’s spell check attribute at true.

Source

pub fn set_non_spell_check(self) -> Self

Sets the field’s spell check attribute at false.

Trait Implementations§

Source§

impl AsHtmlConfig for TextInputConfig

Source§

fn set_html_configs(&self, configs: HtmlElementConfig) -> HtmlElementConfig

Sets the entitie’s properties as html attributes in the givenhtml configs object.
Source§

impl Default for TextInputConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.