Improve checking of form with optional fields
This commit is contained in:
parent
fdfd90a704
commit
d24a363a63
|
@ -42,9 +42,9 @@ impl Default for InputGroup<'_> {
|
|||
}
|
||||
|
||||
impl InputGroup<'_> {
|
||||
fn main_input(&self) -> Markup {
|
||||
fn main_input(&self, force_required: bool) -> Markup {
|
||||
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 {
|
||||
label .form-label for={ (self.name) } { (self.title) }
|
||||
@if self.required {
|
||||
(self.main_input())
|
||||
(self.main_input(false))
|
||||
} @else {
|
||||
.input-group {
|
||||
.input-group-text {
|
||||
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