Additional options for newforms
This ticket and patch try to add new options for inner class "Meta". It depends on #6630. It would fix #3512 and #3515.
All options are independent - it is no problem to accept only a subset.
error_class
- default value - django.newforms.ErrorList
- replaces error_class argument from Form.init
- backward-incompatible - it breaks all forms with argument error_class
- I don't really care about this change (I have never use this argument), but it is consistent with the other options
- default_value - lambda self, formfield: formfield
- function or method (it is normalized as a function) with two arguments - options and a formfield
- it should return a formfield
- it is called during the construction of base fields for the form
- it should be place for general customization and for javascript tricks
- I want to use it for javascript calendars
html_class_for_fields_with_errors
- default_value - errors
- if it is not None, this option is added as an attribute to generated html (by BoundField.row_attrs) - only for fields with errors
- backward-incompatible - it could change generated html, but it could be reverted by setting to None
html_class_for_hidden_fields_row
- default_value - hidden
- if it is not None, this option is added as an attribute to generated html (by Form.hidden_fields_html_output) - only for hidden row
- backward-incompatible - it could change generated html, but it could be reverted by setting to None
html_class_for_required_fields
- default_value - required
- if it is not None, this option is added as an attribute to generated html (by BoundField.row_attrs) - only for required fields
- backward-incompatible - it could change generated html, but it could be reverted by setting to None
label_capitalization
- default_value - True
- if it is True, first letter of labels are capitalized
- it solves a problem of translators - in models first letter of verbose_name should not be capitalized, but in forms first letter should be capitalized - so translator has to translate some words twice
- backward-incompatible - it could change generated html, but it could be reverted by setting to False
label_suffix
- default value - :
- replaces label_suffix argument from Form.init
- backward-incompatible - it breaks all forms with argument label_suffix
- I don't really care about this change (I have never use this argument), but it is consistent with the other options
validation_order
- default value - None
- it could be a list of field names for forms
- if it is None, it changes ordering of fields in validation
- it could be useful in situations where it is necessary to generate and validate forms in different order
Change History
(11)
Needs documentation: |
set
|
Needs tests: |
set
|
Keywords: |
post10 added
|
Triage Stage: |
Unreviewed → Design decision needed
|
Easy pickings: |
unset
|
Resolution: |
→ invalid
|
Status: |
new → closed
|
UI/UX: |
unset
|