From 27746ab28ac88fc213456e63302b408312d95122 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 13 Feb 2020 22:12:46 +0000 Subject: Fixed #7664 -- Allowed customizing suffixes of MultiWidget.widgets' names. --- docs/ref/forms/widgets.txt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'docs/ref/forms') diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 02077f631f..5a54051cda 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -354,7 +354,27 @@ foundation for custom widgets. .. attribute:: MultiWidget.widgets - An iterable containing the widgets needed. + An iterable containing the widgets needed. For example:: + + >>> from django.forms import MultiWidget, TextInput + >>> widget = MultiWidget(widgets=[TextInput, TextInput]) + >>> widget.render('name', ['john', 'paul']) + '' + + You may provide a dictionary in order to specify custom suffixes for + the ``name`` attribute on each subwidget. In this case, for each + ``(key, widget)`` pair, the key will be appended to the ``name`` of the + widget in order to generate the attribute value. You may provide the + empty string (`''`) for a single key, in order to suppress the suffix + for one widget. For example:: + + >>> widget = MultiWidget(widgets={'': TextInput, 'last': TextInput}) + >>> widget.render('name', ['john', 'lennon']) + '' + + .. versionchanged::3.1 + + Support for using a dictionary was added. And one required method: -- cgit v1.3