Created
November 27, 2012 18:21
-
-
Save reedobrien/4156024 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- CORRECT --> | |
<fieldset class="deformMappingFieldset"> | |
<!-- mapping --> | |
<ul> | |
<li class="section"> | |
<div>Please enter your region (i.e. California, Farāh, British Columbia) and country spelled out (i.e. United States, Botswana)</div> | |
</li> | |
<input name="__start__" value="location:mapping" type="hidden"> | |
<li class="field" title="" id="item-deformField10"> | |
<!-- mapping_item --> | |
<label class="desc" title="" for="deformField10">Region (optional) | |
</label> | |
<input name="state" value="" id="deformField10" type="text"> | |
<script type="text/javascript"> | |
deform.addCallback( | |
'deformField10', | |
function (oid) { | |
$('#' + oid).autocomplete({source: "/name/subregions"}); | |
$('#' + oid).autocomplete("option", {"delay": 400, "minLength": 2}); | |
} | |
); | |
</script> | |
<!-- /mapping_item --> | |
</li> | |
<li class="field" title="" id="item-deformField11"> | |
<!-- mapping_item --> | |
<label class="desc" title="" for="deformField11">Country<span class="req" id="req-deformField11">*</span> | |
</label> | |
<input name="country" value="" id="deformField11" type="text"> | |
<script type="text/javascript"> | |
deform.addCallback( | |
'deformField11', | |
function (oid) { | |
$('#' + oid).autocomplete({source: "/name/countries"}); | |
$('#' + oid).autocomplete("option", {"delay": 400, "minLength": 2}); | |
} | |
); | |
</script> | |
<!-- /mapping_item --> | |
</li> | |
<input name="__end__" value="location:mapping" type="hidden"> | |
</ul> | |
<!-- /mapping --> | |
</fieldset> | |
<!-- | |
Which causes the form data to look like this on submission. | |
(u'__start__', u'location:mapping'), | |
(u'state', u''), | |
(u'country', u'lkj'), | |
(u'__end__', u'location:mapping'), | |
This lets colander turn it into a dict like... | |
{"form-data": | |
..., | |
{"contact": | |
... | |
{"state": '', "country": 'lkj'} | |
... | |
}, | |
... | |
} | |
--> | |
<!-- INCORRECT --> | |
<li class="field contactContainer deformItem" title="Please enter your region (i.e. California, Farāh, British Columbia) and country spelled out (i.e. United States, Botswana)" id="item-deformField9"> | |
<!-- mapping_item --> | |
<fieldset class="deformMappingFieldset"> | |
<!-- mapping --> | |
<ul> | |
<li class="section"> | |
<div>Please enter your region (i.e. California, Farāh, British Columbia) and country spelled out (i.e. United States, Botswana)</div> | |
</li> | |
<input name="__start__" value="location:mapping" type="hidden"> | |
<li class="field contactContainer" title="" id="item-deformField10"> | |
<!-- mapping_item --> | |
<label class="desc" title="" for="deformField10">Region (optional) | |
</label> | |
<input aria-haspopup="true" aria-autocomplete="list" role="textbox" autocomplete="off" class="ui-autocomplete-input" name="state" value="" id="deformField10" type="text"> | |
<script type="text/javascript"> | |
deform.addCallback( | |
'deformField10', | |
function (oid) { | |
$('#' + oid).autocomplete({source: "/name/subregions"}); | |
$('#' + oid).autocomplete("option", {"delay": 400, "minLength": 2}); | |
} | |
); | |
</script> | |
<!-- /mapping_item --> | |
</li> | |
<input name="__end__" value="location:mapping" type="hidden"> | |
</ul> | |
<!-- /mapping --> | |
</fieldset> | |
<!-- /mapping_item --> | |
</li> | |
<!-- NOTE THIS IS NOW OUTSIDE THE MAPPING --> | |
<li class="field contactContainer" title="" id="item-deformField11"> | |
<!-- mapping_item --> | |
<label class="desc" title="" for="deformField11">Country<span class="req" id="req-deformField11">*</span> | |
</label> | |
<input aria-haspopup="true" aria-autocomplete="list" role="textbox" autocomplete="off" class="ui-autocomplete-input" name="country" value="" id="deformField11" type="text"> | |
<!-- /mapping_item --> | |
</li> | |
<!-- | |
This causes the submitted for data to look like this: | |
(u'__start__', u'location:mapping'), | |
(u'state', u'foobar'), | |
(u'__end__', u'location:mapping'), | |
(u'country', u'j'), | |
Note that country is now outside the mapping and won't become part of the structure that gets validated so it will always come back as "required" | |
--> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment