Ticket #6920: 0001-Added-working-hidden_widget-to-MultiValueField-692.patch

File 0001-Added-working-hidden_widget-to-MultiValueField-692.patch, 1.9 KB (added by Sebastian Noack, 17 years ago)
  • django/newforms/fields.py

    From d02745f6b5a45f87d4d12b04f76f7900dddfde2a Mon Sep 17 00:00:00 2001
    From: Sebastian Noack <sebastian.noack@gmail.com>
    Date: Mon, 5 May 2008 17:27:43 +0200
    Subject: [PATCH] Added working hidden_widget to MultiValueField (#6920).
    
    ---
     django/newforms/fields.py |    4 +++-
     django/newforms/forms.py  |    3 ++-
     2 files changed, 5 insertions(+), 2 deletions(-)
    
    diff --git a/django/newforms/fields.py b/django/newforms/fields.py
    index 08e8b84..01b364b 100644
    a b from django.utils.translation import ugettext_lazy as _  
    2121from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str
    2222
    2323from util import ErrorList, ValidationError
    24 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput
     24from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput, MultiWidget
    2525
    2626
    2727__all__ = (
    class MultiValueField(Field):  
    671671            f.required = False
    672672        self.fields = fields
    673673
     674        self.hidden_widget = MultiWidget([f.hidden_widget for f in fields])
     675
    674676    def clean(self, value):
    675677        """
    676678        Validates every value in the given list. A value is validated against
  • django/newforms/forms.py

    diff --git a/django/newforms/forms.py b/django/newforms/forms.py
    index 2c481e4..55223eb 100644
    a b class BoundField(StrAndUnicode):  
    306306        """
    307307        Returns a string of HTML for representing this as an <input type="hidden">.
    308308        """
    309         return self.as_widget(self.field.hidden_widget(), attrs)
     309        w = self.field.hidden_widget
     310        return self.as_widget(isinstance(w, type) and w() or w, attrs)
    310311
    311312    def _data(self):
    312313        """
Back to Top