Parcourir la source

Set MacAddressFormField widget's maxlength since it is no longer pulled from model validator.

Sebastian Brandt il y a 10 ans
Parent
commit
e69cb6a7c2
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      netfields/forms.py

+ 5 - 0
netfields/forms.py

@@ -84,3 +84,8 @@ class MACAddressFormField(forms.Field):
             return EUI(value, dialect=mac_unix_common)
         except (AddrFormatError, TypeError):
             raise ValidationError(self.error_messages['invalid'])
+
+    def widget_attrs(self, widget):
+        attrs = super(MACAddressFormField, self).widget_attrs(widget)
+        attrs.update({'maxlength': '17'})
+        return attrs