red-tape/input/index.html @ e0132bd24efe
cl-ggp: Update site.
author |
Steve Losh <steve@stevelosh.com> |
date |
Thu, 24 Mar 2016 14:03:46 +0000 |
parents |
f1d02f8944b8 |
children |
69831b3947d7 |
<html><head><title>Form Input / Red Tape</title><link rel="stylesheet" href="../_dmedia/bootstrap.css"/><link rel="stylesheet" href="../_dmedia/tango.css"/><link rel="stylesheet/less" type="text/css" href="../_dmedia/style.less"/><script src="../_dmedia/less.js" type="text/javascript">
</script></head><body class="content">
<div class="wrap">
<header><h1><a href="..">Red Tape</a></h1></header><div class="markdown">
<h1 id="form-input"><a href="">Form Input</a></h1><p>Red Tape forms take a map of data as input. Red Tape is designed with web-based
forms in mind, but since it operates on plain old maps you could certainly use
it for other things as well.</p>
<div class="toc">
<ul><li><a href="#keys">Keys</a></li>
<li><a href="#values">Values</a></li>
</ul></div>
<h2 id="keys">Keys</h2>
<p>The input map should contain keys that match the field definitions of a form.
For example:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">defform</span> <span class="nv">change-password-form</span> <span class="p">{}</span>
<span class="ss">:old-password</span> <span class="p">[</span><span class="nv">...</span><span class="p">]</span>
<span class="ss">:new-password-1</span> <span class="p">[</span><span class="nv">...</span><span class="p">]</span>
<span class="ss">:new-password-2</span> <span class="p">[</span><span class="nv">...</span><span class="p">])</span>
<span class="p">(</span><span class="nf">change-password-form</span> <span class="p">{</span><span class="ss">:old-password</span> <span class="s">"foo"</span>
<span class="ss">:new-password-1</span> <span class="s">"bar"</span>
<span class="ss">:new-password-2</span> <span class="s">"bar"</span><span class="p">})</span>
<span class="c1">; =></span>
<span class="p">{</span><span class="nv">...</span> <span class="nv">result</span> <span class="nb">map </span><span class="nv">...</span><span class="p">}</span>
</pre></div>
<p>For convenience, the keys in the input map can be strings and everything will
still work:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">change-password-form</span> <span class="p">{</span><span class="s">"old-password"</span> <span class="s">"foo"</span>
<span class="s">"new-password-1"</span> <span class="s">"bar"</span>
<span class="s">"new-password-2"</span> <span class="s">"bar"</span><span class="p">})</span>
<span class="c1">; =></span>
<span class="p">{</span><span class="nv">...</span> <span class="nv">result</span> <span class="nb">map </span><span class="nv">...</span><span class="p">}</span>
</pre></div>
<p>If the input map contains both a string and a keyword key for a field, the
results are undefined. Don't do that.</p>
<h2 id="values">Values</h2>
<p>All values in the input map should be strings.</p>
<p>Using other types of data may <em>appear</em> to work, but Red Tape's behavior may
change in the future so you really should just stick to string input and use
cleaners to convert them to whatever kind of data you want.</p>
<p>Move on to the <a href="../cleaners/">cleaners</a> guide to learn more about this.</p>
</div>
<footer><p>Made and <a href="http://sjl.bitbucket.org/d/">documented</a> with love by <a href="http://stevelosh.com">Steve
Losh</a>.</p>
<p><br/><a id="rochester-made" href="http://rochestermade.com" title="Rochester Made"><img src="http://rochestermade.com/media/images/rochester-made-dark-on-light.png" alt="Rochester Made" title="Rochester Made"/></a></p></footer></div>
</body></html>