1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
//! InputUrl - Controller (field type)
use core::fmt::Debug;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct InputUrl {
pub id: String, // The value is determined automatically. Format: "model-name--field-name".
pub label: String, // Web form field name.
pub field_type: String, // Field type.
pub input_type: String, // The value is determined automatically.
pub name: String, // The value is determined automatically.
pub value: Option<String>, // Sets the value of an element.
pub default: Option<String>, // Value by default.
pub placeholder: String, // Displays prompt text.
pub pattern: String, // Validating a field using a client-side regex (Only for text, search, tel, url, email, and password controls).
pub minlength: usize, // The minimum number of characters allowed in the text.
pub maxlength: usize, // The maximum number of characters allowed in the text.
pub required: bool, // Mandatory field.
pub unique: bool, // The unique value of a field in a collection.
pub disabled: bool, // Blocks access and modification of the element.
pub readonly: bool, // Specifies that the field cannot be modified by the user.
pub is_hide: bool, // Hide field from user.
pub other_attrs: String, // Example: r# "autofocus tabindex="some number" size="some numberString::new()#.
pub css_classes: String, // Example: "class-name-1 class-name-2".
pub hint: String, // Additional explanation for the user.
pub warning: String, // Warning information.
pub error: String, // The value is determined automatically.
pub group: u32, // To optimize field traversal in the `paladins/check()` method. Hint: It is recommended not to change.
}
impl Default for InputUrl {
fn default() -> Self {
Self {
id: String::new(),
label: String::new(),
field_type: String::from("InputUrl"),
input_type: String::from("url"),
name: String::new(),
value: None,
default: None,
placeholder: String::new(),
pattern: String::new(),
minlength: 0,
maxlength: 256,
required: false,
unique: false,
disabled: false,
readonly: false,
is_hide: false,
other_attrs: String::new(),
css_classes: String::new(),
hint: String::new(),
warning: String::new(),
error: String::new(),
group: 1,
}
}
}
impl InputUrl {
pub fn get(&self) -> Option<String> {
self.value.clone()
}
pub fn set(&mut self, value: &str) {
self.value = Some(String::from(value));
}
}