Ticket #11632: show_hidden_initial.diff
File show_hidden_initial.diff, 1.7 KB (added by , 15 years ago) |
---|
-
django/forms/forms.py
343 343 self.name = name 344 344 self.html_name = form.add_prefix(name) 345 345 self.html_initial_name = form.add_initial_prefix(name) 346 self.html_initial_id = form.add_initial_prefix(self.auto_id) 346 347 if self.field.label is None: 347 348 self.label = pretty_name(name) 348 349 else: … … 374 375 attrs = attrs or {} 375 376 auto_id = self.auto_id 376 377 if auto_id and 'id' not in attrs and 'id' not in widget.attrs: 377 attrs['id'] = auto_id 378 if not only_initial: 379 attrs['id'] = auto_id 380 else: 381 attrs['id'] = self.html_initial_id 378 382 if not self.form.is_bound: 379 383 data = self.form.initial.get(self.name, self.field.initial) 380 384 if callable(data): -
tests/regressiontests/forms/forms.py
1807 1807 >>> [f.name for f in form.visible_fields()] 1808 1808 ['artist', 'name'] 1809 1809 1810 # Hidden initial input gets its own unique id ################################ 1811 1812 >>> class MyForm(Form): 1813 ... field1 = CharField(max_length=50, show_hidden_initial=True) 1814 >>> print MyForm() 1815 <tr><th><label for="id_field1">Field1:</label></th><td><input id="id_field1" type="text" name="field1" maxlength="50" /><input type="hidden" name="initial-field1" id="initial-id_field1" /></td></tr> 1816 1810 1817 """