Improve checking of form with optional fields
This commit is contained in:
parent
06a1137377
commit
e3b9b64a53
|
@ -42,9 +42,9 @@ impl Default for InputGroup<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputGroup<'_> {
|
impl InputGroup<'_> {
|
||||||
fn main_input(&self) -> Markup {
|
fn main_input(&self, force_required: bool) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
input .form-control #(self.name) name={ (self.name) } type={ (self.r#type) } required[self.required] disabled[self.disabled] value=[self.value.clone()];
|
input .form-control #(self.name) name={ (self.name) } type={ (self.r#type) } required[self.required || force_required] disabled[self.disabled] value=[self.value.clone()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,13 +55,13 @@ impl Render for InputGroup<'_> {
|
||||||
.mb-3 {
|
.mb-3 {
|
||||||
label .form-label for={ (self.name) } { (self.title) }
|
label .form-label for={ (self.name) } { (self.title) }
|
||||||
@if self.required {
|
@if self.required {
|
||||||
(self.main_input())
|
(self.main_input(false))
|
||||||
} @else {
|
} @else {
|
||||||
.input-group {
|
.input-group {
|
||||||
.input-group-text {
|
.input-group-text {
|
||||||
input .form-check-input.mt-0.input-toggle type="checkbox" checked[!self.disabled];
|
input .form-check-input.mt-0.input-toggle type="checkbox" checked[!self.disabled];
|
||||||
}
|
}
|
||||||
(self.main_input())
|
(self.main_input(true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue