1
0
mirror of https://github.com/django/django.git synced 2025-06-05 11:39:13 +00:00

Fixed #35889 -- Corrected reference of default widgets in "Styling widget instance" docs.

This commit is contained in:
antoliny0919 2024-11-06 18:47:54 +09:00 committed by Sarah Boyce
parent 5c3b9d04d2
commit 18b3a9dd39

View File

@ -142,9 +142,9 @@ For example, take the following form::
url = forms.URLField() url = forms.URLField()
comment = forms.CharField() comment = forms.CharField()
This form will include three default :class:`TextInput` widgets, with default This form will include :class:`TextInput` widgets for the name and comment
rendering -- no CSS class, no extra attributes. This means that the input boxes fields, and a :class:`URLInput` widget for the url field. Each has default
provided for each widget will be rendered exactly the same: rendering - no CSS class, no extra attributes:
.. code-block:: pycon .. code-block:: pycon
@ -154,11 +154,11 @@ provided for each widget will be rendered exactly the same:
<div>Url:<input type="url" name="url" required></div> <div>Url:<input type="url" name="url" required></div>
<div>Comment:<input type="text" name="comment" required></div> <div>Comment:<input type="text" name="comment" required></div>
On a real web page, you probably don't want every widget to look the same. You On a real web page, you probably want to customize this. You might want a
might want a larger input element for the comment, and you might want the larger input element for the comment, and you might want the 'name' widget to
'name' widget to have some special CSS class. It is also possible to specify have some special CSS class. It is also possible to specify the 'type'
the 'type' attribute to take advantage of the new HTML5 input types. To do attribute to use a different HTML5 input type. To do this, you use the
this, you use the :attr:`Widget.attrs` argument when creating the widget:: :attr:`Widget.attrs` argument when creating the widget::
class CommentForm(forms.Form): class CommentForm(forms.Form):
name = forms.CharField(widget=forms.TextInput(attrs={"class": "special"})) name = forms.CharField(widget=forms.TextInput(attrs={"class": "special"}))