Skip to content

Commit

Permalink
Add values for selection lists, so that input elements get rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
jean committed Aug 8, 2013
1 parent 47d5302 commit 104f2ac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Products/CMFPlomino/tests/plomino.txt
Expand Up @@ -173,7 +173,7 @@ Only items which match a form field will be considered::

>>> doc1.setItem('field1', 'where is my mind?')
>>> db.frm1.displayDocument(doc1, editmode=False)
u"2 <p>please enter a value for field1:<span class='label' title='Label for field1'>Title for field1</span><span>\n \n \n where is my mind?\n \n</span>\n</p><p>Comment:<span class='label' title='Title for field2'>Title for field2</span><span>\n \n \n My favorite song is where is my mind?\n \n</span>\n</p><p><span>\n \n \n WHERE IS MY MIND?\n \n</span>\n</p><p><span>\n \n \n side-effect\n \n</span>\n</p>"
u"2 <p>please enter a value for field1:<span class='label' title='Label for field1'>Title for field1</span><span>\n \n \n where is my mind?\n \n</span>\n</p><p>Comment:<span class='label' title='Label for field2'>Title for field2</span><span>\n \n \n My favorite song is where is my mind?\n \n</span>\n</p><p><span>\n \n \n WHERE IS MY MIND?\n \n</span>\n</p><p><span>\n \n \n side-effect\n \n</span>\n</p>"
>>> db.frm1.displayDocument(doc1, editmode=True)
u'<input type=\'hidden\' name=\'Form\' value=\'frm1\' />2 <p>please enter a value for field1:<label for=\'field1\' class=\'required\'>Title for field1</label><span>\n \n \n <input type="text" name="field1" value="where is my mind?" />\n \n \n</span>\n</p><p>Comment:<label for=\'field2\'>Title for field2</label><span>\n \n \n My favorite song is where is my mind?\n \n</span>\n</p><p><span>\n \n \n WHERE IS MY MIND?\n \n</span>\n</p><p><span>\n \n \n side-effect\n \n</span>\n</p>'

Expand Down Expand Up @@ -351,16 +351,18 @@ The default text widget is a basic HTML text input::
... """)
>>> adapted = ISelectionField(db.frm2.bassist)
>>> adapted.widget = "CHECKBOX"
>>> adapted.selectionlist = ["John Paul Jones", "Chris Chameleon"]
>>> adapted.selectionlist = [u"John Paul Jones", u"Chris Chameleon"]
>>> adapted = ISelectionField(db.frm2.drummer)
>>> adapted.widget = "RADIO"
>>> adapted.selectionlist = ["John Bonham", "Princess Leonie"]
>>> adapted.selectionlist = [u"John Bonham", u"Princess Leonie"]
>>> db.frm2.displayDocument(None, True, True).replace('\n', '').replace('\t', '')
u'<input type=\'hidden\' name=\'Form\' value=\'frm2\' />3 <p>Who is the guitarist:<label for=\'guitarist\'>Title for guitarist</label></p><span> <input type="text" name="guitarist" value="" /> </span></p></p><fieldset><legend class="required">Label for bassist</legend><span></span></fieldset></p></p><fieldset><legend>Title for drummer</legend><span></span></fieldset></p>'
u'<input type=\'hidden\' name=\'Form\' value=\'frm2\' />3 <p>Who is the guitarist:<label for=\'guitarist\'>Title for guitarist</label></p><span> <input type="text" name="guitarist" value="" /> </span></p></p><fieldset><legend class=\'required\'>Label for bassist</legend><span><input type="checkbox" name="bassist" value="John Paul Jones" id="bassist-John Paul Jones"><label for="bassist-John Paul Jones">John Paul Jones</label><input type="checkbox" name="bassist" value="Chris Chameleon" id="bassist-Chris Chameleon"><label for="bassist-Chris Chameleon">Chris Chameleon</label></span></fieldset></p></p><fieldset><legend>Title for drummer</legend><span><input type="radio" name="drummer" value="John Bonham" id="drummer-John Bonham"><label for="drummer-John Bonham">John Bonham</label><input type="radio" name="drummer" value="Princess Leonie" id="drummer-Princess Leonie"><label for="drummer-Princess Leonie">Princess Leonie</label></span></fieldset></p>'
>>> adapted = ITextField(db.frm2.guitarist)
>>> adapted.widget="TEXTAREA"
>>> db.frm2.displayDocument(None, True, True).replace('\n', '').replace('\t', '')
u'<input type=\'hidden\' name=\'Form\' value=\'frm2\' />3 <p>Who is the guitarist:<label for=\'guitarist\'>Title for guitarist</label></p><span> <textarea name="guitarist"></textarea> </span></p></p><fieldset><legend>Label for bassist</legend><span></span></fieldset></p></p><fieldset><legend>Title for drummer</legend><span></span></fieldset></p>'
u'<input type=\'hidden\' name=\'Form\' value=\'frm2\' />3 <p>Who is the guitarist:<label for=\'guitarist\'>Title for guitarist</label></p><span> <textarea name="guitarist"></textarea> </span></p></p><fieldset><legend class=\'required\'>Label for bassist</legend><span><input type="checkbox" name="bassist" value="John Paul Jones" id="bassist-John Paul Jones"><label for="bassist-John Paul Jones">John Paul Jones</label><input type="checkbox" name="bassist" value="Chris Chameleon" id="bassist-Chris Chameleon"><label for="bassist-Chris Chameleon">Chris Chameleon</label></span></fieldset></p></p><fieldset><legend>Title for drummer</legend><span><input type="radio" name="drummer" value="John Bonham" id="drummer-John Bonham"><label for="drummer-John Bonham">John Bonham</label><input type="radio" name="drummer" value="Princess Leonie" id="drummer-Princess Leonie"><label for="drummer-Princess Leonie">Princess Leonie</label></span></fieldset></p>'

.. todo:: We need a test for a selection list with no value in edit mode. It should not render a label.

Selection field::

Expand Down

0 comments on commit 104f2ac

Please sign in to comment.