#29205: MultiValueField ignores a required value of a sub field
--------------------------------+------------------------------------
Reporter: Takayuki Hirai | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Comment (by jhrr):
I also bumped into this a while back during a project and promptly forgot
about it. In my case I fixed it by overrriding `render` like so:
{{{
def render(self, name, value, attrs=None):
if self.is_localized:
for widget in self.widgets:
widget.is_localized = self.is_localized
if not isinstance(value, list):
value = self.decompress(value)
output = []
final_attrs = self.build_attrs(attrs)
id_ = final_attrs.get("id")
for i, widget in enumerate(self.widgets):
try:
widget_value = value[i]
except IndexError:
widget_value = None
if id_:
final_attrs = dict(final_attrs, id="%s_%s" % (id_, i))
final_attrs["required"] = widget.is_required # ADDED
output.append(widget.render(name + "_%s" % i, widget_value,
final_attrs))
return mark_safe(self.format_output(output))
}}}
Whether that is optimal however I wasn't able to fully ascertain.
--
Ticket URL: <https://code.djangoproject.com/ticket/29205#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.17d89d99add25043c9964f8c6c425f16%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.