@@ -10,9 +10,7 @@ use cot::form::FormField;
1010use cot:: form:: fields:: impl_form_field;
1111use cot:: html:: HtmlTag ;
1212
13- use crate :: form:: fields:: {
14- SelectChoice , SelectField , SelectMultipleField , Step , check_required, check_required_multiple,
15- } ;
13+ use crate :: form:: fields:: { SelectChoice , SelectField , Step , check_required} ;
1614use crate :: form:: { AsFormField , FormFieldValidationError } ;
1715
1816impl AsFormField for Weekday {
@@ -29,39 +27,7 @@ impl AsFormField for Weekday {
2927 }
3028}
3129
32- macro_rules! impl_as_form_field_mult {
33- ( $field_type: ty) => {
34- impl_as_form_field_mult_collection!( :: std:: vec:: Vec <$field_type>, $field_type) ;
35- impl_as_form_field_mult_collection!( :: std:: collections:: VecDeque <$field_type>, $field_type) ;
36- impl_as_form_field_mult_collection!(
37- :: std:: collections:: LinkedList <$field_type>,
38- $field_type
39- ) ;
40- impl_as_form_field_mult_collection!( :: std:: collections:: HashSet <$field_type>, $field_type) ;
41- impl_as_form_field_mult_collection!( :: indexmap:: IndexSet <$field_type>, $field_type) ;
42- } ;
43- }
44-
45- macro_rules! impl_as_form_field_mult_collection {
46- ( $collection_type: ty, $field_type: ty) => {
47- impl AsFormField for $collection_type {
48- type Type = SelectMultipleField <$field_type>;
49-
50- fn clean_value( field: & Self :: Type ) -> Result <Self , FormFieldValidationError > {
51- let value = check_required_multiple( field) ?;
52-
53- value. iter( ) . map( |id| <$field_type>:: from_str( id) ) . collect( )
54- }
55-
56- fn to_field_value( & self ) -> String {
57- String :: new( )
58- }
59- }
60- } ;
61- }
62-
63- impl_as_form_field_mult ! ( Weekday ) ;
64- impl_as_form_field_mult_collection ! ( WeekdaySet , Weekday ) ;
30+ crate :: form:: fields:: select:: impl_as_form_field_mult_collection!( ( ) => WeekdaySet , Weekday ) ;
6531
6632const MONDAY_ID : & str = "mon" ;
6733const TUESDAY_ID : & str = "tue" ;
@@ -730,7 +696,9 @@ mod tests {
730696 use cot:: form:: FormFieldValue ;
731697
732698 use super :: * ;
733- use crate :: form:: fields:: { SelectFieldOptions , SelectMultipleFieldOptions } ;
699+ use crate :: form:: fields:: {
700+ SelectFieldOptions , SelectMultipleField , SelectMultipleFieldOptions ,
701+ } ;
734702 use crate :: form:: { FormField , FormFieldOptions } ;
735703
736704 #[ test]
0 commit comments