]> saetta.ns0.it Git - rust/zakform/commitdiff
Added Form::remove_field.
authorAndrea Zagli <azagli@libero.it>
Sun, 5 Mar 2023 09:15:35 +0000 (10:15 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 5 Mar 2023 09:15:35 +0000 (10:15 +0100)
src/form.rs

index 8769a4ffe425c290b55ccc2b8089a1b5a06b0ca0..24a88a9acf388eb2f6aaa29dfb7db96324c0835b 100644 (file)
@@ -13,6 +13,16 @@ impl Form {
                self.fields.push(field);
        }
 
+       pub fn remove_field(&mut self, field_name: &str) {
+               let mut i = 0;
+               while i < self.fields.len() {
+                       if self.fields[i].get_name() == field_name {
+                               self.fields.remove(i);
+                       }
+                       i += 1;
+               }
+       }
+
        pub fn fields(&mut self) -> Vec<&mut Box<dyn super::fields::TField>> {
                let mut v = vec![];