diff options
| author | Brian Rosner <brosner@gmail.com> | 2008-09-01 21:28:32 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2008-09-01 21:28:32 +0000 |
| commit | 7c7ad041b358a9819b3bd9f93d4834df4a5b5d57 (patch) | |
| tree | 0db25e5aa8a42c9678695d4130bd562f673069eb /django/forms/fields.py | |
| parent | ca7db155aa32d659c5fc0fc01a50e844af798845 (diff) | |
Fixed #7975 -- Callable defaults in inline model formsets now work correctly. Based on patch from msaelices. Thanks for your hard work msaelices.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8816 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/fields.py')
| -rw-r--r-- | django/forms/fields.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index e267498808..b20beb939f 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -28,7 +28,7 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_unicode, smart_str from util import ErrorList, ValidationError -from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput, TimeInput +from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput, TimeInput, SplitHiddenDateTimeWidget from django.core.files.uploadedfile import SimpleUploadedFile as UploadedFile __all__ = ( @@ -59,7 +59,7 @@ class Field(object): creation_counter = 0 def __init__(self, required=True, widget=None, label=None, initial=None, - help_text=None, error_messages=None): + help_text=None, error_messages=None, show_hidden_initial=False): # required -- Boolean that specifies whether the field is required. # True by default. # widget -- A Widget class, or instance of a Widget class, that should @@ -73,9 +73,12 @@ class Field(object): # initial -- A value to use in this Field's initial display. This value # is *not* used as a fallback if data isn't given. # help_text -- An optional string to use as "help text" for this Field. + # show_hidden_initial -- Boolean that specifies if it is needed to render a + # hidden widget with initial value after widget. if label is not None: label = smart_unicode(label) self.required, self.label, self.initial = required, label, initial + self.show_hidden_initial = show_hidden_initial if help_text is None: self.help_text = u'' else: @@ -840,6 +843,7 @@ class FilePathField(ChoiceField): self.widget.choices = self.choices class SplitDateTimeField(MultiValueField): + hidden_widget = SplitHiddenDateTimeWidget default_error_messages = { 'invalid_date': _(u'Enter a valid date.'), 'invalid_time': _(u'Enter a valid time.'), |
