diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-01-20 23:09:10 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-21 02:09:10 -0500 |
| commit | ff05de760cc4ef4c7f188e163c722ec3bc1f0cbf (patch) | |
| tree | ba133d0ecea7521935c98cf1c058df4e6a9ff233 /docs/ref/forms/fields.txt | |
| parent | 4b0f39d9fb2033a9597e30ac13af162440b82ebc (diff) | |
Fixed #29038 -- Removed closing slash from HTML void tags.
Diffstat (limited to 'docs/ref/forms/fields.txt')
| -rw-r--r-- | docs/ref/forms/fields.txt | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 6c24c3534e..65a231d8e2 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -119,9 +119,9 @@ We've specified ``auto_id=False`` to simplify the output:: ... comment = forms.CharField() >>> f = CommentForm(auto_id=False) >>> print(f) - <tr><th>Your name:</th><td><input type="text" name="name" required /></td></tr> - <tr><th>Your website:</th><td><input type="url" name="url" /></td></tr> - <tr><th>Comment:</th><td><input type="text" name="comment" required /></td></tr> + <tr><th>Your name:</th><td><input type="text" name="name" required></td></tr> + <tr><th>Your website:</th><td><input type="url" name="url"></td></tr> + <tr><th>Comment:</th><td><input type="text" name="comment" required></td></tr> ``label_suffix`` ---------------- @@ -137,9 +137,9 @@ The ``label_suffix`` argument lets you override the form's ... captcha_answer = forms.IntegerField(label='2 + 2', label_suffix=' =') >>> f = ContactForm(label_suffix='?') >>> print(f.as_p()) - <p><label for="id_age">Age?</label> <input id="id_age" name="age" type="number" required /></p> - <p><label for="id_nationality">Nationality?</label> <input id="id_nationality" name="nationality" type="text" required /></p> - <p><label for="id_captcha_answer">2 + 2 =</label> <input id="id_captcha_answer" name="captcha_answer" type="number" required /></p> + <p><label for="id_age">Age?</label> <input id="id_age" name="age" type="number" required></p> + <p><label for="id_nationality">Nationality?</label> <input id="id_nationality" name="nationality" type="text" required></p> + <p><label for="id_captcha_answer">2 + 2 =</label> <input id="id_captcha_answer" name="captcha_answer" type="number" required></p> ``initial`` ----------- @@ -161,9 +161,9 @@ field is initialized to a particular value. For example:: ... comment = forms.CharField() >>> f = CommentForm(auto_id=False) >>> print(f) - <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required /></td></tr> - <tr><th>Url:</th><td><input type="url" name="url" value="http://" required /></td></tr> - <tr><th>Comment:</th><td><input type="text" name="comment" required /></td></tr> + <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required></td></tr> + <tr><th>Url:</th><td><input type="url" name="url" value="http://" required></td></tr> + <tr><th>Comment:</th><td><input type="text" name="comment" required></td></tr> You may be thinking, why not just pass a dictionary of the initial values as data when displaying the form? Well, if you do that, you'll trigger validation, @@ -176,9 +176,9 @@ and the HTML output will include any validation errors:: >>> default_data = {'name': 'Your name', 'url': 'http://'} >>> f = CommentForm(default_data, auto_id=False) >>> print(f) - <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required /></td></tr> - <tr><th>Url:</th><td><ul class="errorlist"><li>Enter a valid URL.</li></ul><input type="url" name="url" value="http://" required /></td></tr> - <tr><th>Comment:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="comment" required /></td></tr> + <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required></td></tr> + <tr><th>Url:</th><td><ul class="errorlist"><li>Enter a valid URL.</li></ul><input type="url" name="url" value="http://" required></td></tr> + <tr><th>Comment:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="comment" required></td></tr> This is why ``initial`` values are only displayed for unbound forms. For bound forms, the HTML output will use the bound data. @@ -205,7 +205,7 @@ Instead of a constant, you can also pass any callable:: >>> class DateForm(forms.Form): ... day = forms.DateField(initial=datetime.date.today) >>> print(DateForm()) - <tr><th>Day:</th><td><input type="text" name="day" value="12/23/2008" required /><td></tr> + <tr><th>Day:</th><td><input type="text" name="day" value="12/23/2008" required><td></tr> The callable will be evaluated only when the unbound form is displayed, not when it is defined. @@ -241,20 +241,20 @@ fields. We've specified ``auto_id=False`` to simplify the output:: ... cc_myself = forms.BooleanField(required=False) >>> f = HelpTextContactForm(auto_id=False) >>> print(f.as_table()) - <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" required /><br /><span class="helptext">100 characters max.</span></td></tr> - <tr><th>Message:</th><td><input type="text" name="message" required /></td></tr> - <tr><th>Sender:</th><td><input type="email" name="sender" required /><br />A valid email address, please.</td></tr> - <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself" /></td></tr> + <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" required><br><span class="helptext">100 characters max.</span></td></tr> + <tr><th>Message:</th><td><input type="text" name="message" required></td></tr> + <tr><th>Sender:</th><td><input type="email" name="sender" required><br>A valid email address, please.</td></tr> + <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself"></td></tr> >>> print(f.as_ul())) - <li>Subject: <input type="text" name="subject" maxlength="100" required /> <span class="helptext">100 characters max.</span></li> - <li>Message: <input type="text" name="message" required /></li> - <li>Sender: <input type="email" name="sender" required /> A valid email address, please.</li> - <li>Cc myself: <input type="checkbox" name="cc_myself" /></li> + <li>Subject: <input type="text" name="subject" maxlength="100" required> <span class="helptext">100 characters max.</span></li> + <li>Message: <input type="text" name="message" required></li> + <li>Sender: <input type="email" name="sender" required> A valid email address, please.</li> + <li>Cc myself: <input type="checkbox" name="cc_myself"></li> >>> print(f.as_p()) - <p>Subject: <input type="text" name="subject" maxlength="100" required /> <span class="helptext">100 characters max.</span></p> - <p>Message: <input type="text" name="message" required /></p> - <p>Sender: <input type="email" name="sender" required /> A valid email address, please.</p> - <p>Cc myself: <input type="checkbox" name="cc_myself" /></p> + <p>Subject: <input type="text" name="subject" maxlength="100" required> <span class="helptext">100 characters max.</span></p> + <p>Message: <input type="text" name="message" required></p> + <p>Sender: <input type="email" name="sender" required> A valid email address, please.</p> + <p>Cc myself: <input type="checkbox" name="cc_myself"></p> ``error_messages`` ------------------ |
