Django

Code

Changeset 4143

Show
Ignore:
Timestamp:
11/29/06 15:48:58 (2 years ago)
Author:
adrian
Message:

newforms: Added BoundField?.data property

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/forms.py

    r4136 r4143  
    183183        if auto_id and not attrs.has_key('id') and not widget.attrs.has_key('id'): 
    184184            attrs['id'] = auto_id 
    185         return widget.render(self._name, self._form.data.get(self._name, None), attrs=attrs) 
     185        return widget.render(self._name, self.data, attrs=attrs) 
    186186 
    187187    def as_text(self, attrs=None): 
     
    194194        "Returns a string of HTML for representing this as a <textarea>." 
    195195        return self.as_widget(Textarea(), attrs) 
     196 
     197    def _data(self): 
     198        "Returns the data for this BoundField, or None if it wasn't given." 
     199        return self._form.data.get(self._name, None) 
     200    data = property(_data) 
    196201 
    197202    def _verbose_name(self): 
  • django/trunk/tests/regressiontests/forms/tests.py

    r4136 r4143  
    12691269<input type="text" name="last_name" value="Lennon" /> 
    12701270<input type="text" name="birthday" value="1940-10-9" /> 
     1271>>> for boundfield in p: 
     1272...     print boundfield.verbose_name, boundfield.data 
     1273First name John 
     1274Last name Lennon 
     1275Birthday 1940-10-9 
    12711276>>> print p 
    12721277<tr><td>First name:</td><td><input type="text" name="first_name" value="John" /></td></tr>