#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:  Unreviewed
    Has patch:  0               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  0
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+--------------------------------------

Comment (by Takayuki Hirai):

 I tried to remove {{{required=False}}}, then both INPUT elements in HTML
 became {{{required}}}.

 {{{
 <tr><th><label for="id_mf_0">Mf:</label></th><td><input type="text"
 name="mf_0" required id="id_mf_0" />

 <input type="text" name="mf_1" required id="id_mf_1" /></td></tr>
 }}}

 Code:

 {{{
 #!python
 class MW(MultiWidget):
     def decompress(self, value):
         return []


 class MF(MultiValueField):
     widget = MW

     def __init__(self):
         fields = [
             CharField(required=False),
             CharField(required=True),
         ]
         widget = self.widget(widgets=[
             f.widget
             for f in fields
         ], attrs={})
         super(MF, self).__init__(
             fields=fields,
             widget=widget,
             require_all_fields=False,
             required=True,
         )

     def compress(self, value):
         return []
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29205#comment:3>
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.ffc7a44bd2e2e5cc1be90b7040c7bbf7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to