Location: PHPKode > projects > Pieforms > pieforms-php5-0.2.2/doc/html/user/usage.html
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns=http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
<title>Pieforms Usage</title>

<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<div class="document" id="pieforms-usage">
<h1 class="title">Pieforms Usage</h1>
<p><div id="breadcrumbs"><a href="http://pieforms.sourceforge.net/">Pieforms Home</a> &raquo; <a href="../">Documentation Home</a> &raquo; <a href="">Pieforms Usage</a></div></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Nigel McNie</td>
</tr>
<tr class="field"><th class="field-name">Contact:</th><td class="field-body"><a class="reference" href="mailto:nigel&#64;catalyst.net.nz">nigel&#64;catalyst.net.nz</a></td>
</tr>
<tr class="field"><th class="field-name">Copyright:</th><td class="field-body">This document has been placed in the public domain</td>
</tr>
</tbody>
</table>
<div class="contents topic">
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
<ul class="simple">
<li><a class="reference" href="#before-you-begin" id="id1" name="id1">Before You Begin...</a></li>
<li><a class="reference" href="#your-first-pieform" id="id2" name="id2">Your First Pieform</a><ul>
<li><a class="reference" href="#the-basics" id="id3" name="id3">The Basics</a></li>
<li><a class="reference" href="#adding-a-touch-of-class" id="id4" name="id4">Adding a Touch of Class</a></li>
<li><a class="reference" href="#the-finishing-touches" id="id5" name="id5">The Finishing Touches</a></li>
</ul>
</li>
<li><a class="reference" href="#a-form-with-wings" id="id6" name="id6">A Form With Wings</a><ul>
<li><a class="reference" href="#overview" id="id7" name="id7">Overview</a></li>
<li><a class="reference" href="#making-a-form-work-quickly" id="id8" name="id8">Making a Form Work Quickly</a></li>
</ul>
</li>
<li><a class="reference" href="#conclusion" id="id9" name="id9">Conclusion</a></li>
</ul>
</div>
<p>This document takes you through the creation of a Pieform, step by step. After
reading this document, you should be able to put together all manner of
Pieforms, and you will be ready to begin learning how to create your own
plugins for your own needs.</p>
<div class="section">
<h1><a class="toc-backref" href="#id1" id="before-you-begin" name="before-you-begin">Before You Begin...</a></h1>
<p>Make sure that you have <a class="reference" href="concepts.html">read the concepts document</a>, so that
you understand the basic ideas behind how Pieforms works. Also make sure you
have <a class="reference" href="configuration.html">installed</a> Pieforms, of course!</p>
</div>
<div class="section">
<h1><a class="toc-backref" href="#id2" id="your-first-pieform" name="your-first-pieform">Your First Pieform</a></h1>
<p>For the sake of argument, let us assume that you are writing a blogging application, and that your current task is to write a form into which new posts will be entered. This form will consist of:</p>
<ul class="simple">
<li>A text box, for the subject</li>
<li>A textarea, for the post content</li>
<li>A multiple-select dropdown, for choosing categories for the post</li>
<li>A date field for choosing the date on which the post will become viewable, defaulting to the current date</li>
<li>A submit and cancel button</li>
</ul>
<p>Also, for the sake of argument, let us assume that the category selection and date fields are optional and not really used that much, so we will place them in a fieldset and collapse it by default, to make the form seem simpler for general use.</p>
<p>So, given these requirements, let's get started!</p>
<div class="section">
<h2><a class="toc-backref" href="#id3" id="the-basics" name="the-basics">The Basics</a></h2>
<p>We shall start with the basic page shell, and build the pieces as required. Here is the most basic shell:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>And here is the output you get when running this:</p>
<p>[insert screenshot here of boom]</p>
<p>Whoops! Pieforms forms <strong>must</strong> have a name. This name is used on the client side to identify the form, and on the server side to provide unique names for the validation/submission callbacks. More on those later, but for now let's add some of the most basic parameters required:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">blogpost</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>[insert screenshot of boom]</p>
<p>So now the form has a name, and will be sent by POST when submitted. But it has no elements! There's not too much point in having a form that does not have an element, so lets add the title field and submit/cancel buttons.</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">blogpost</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Post Title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>[insert screenshot of yay]</p>
<p>Now we have some concrete progress, at last! We now have a single text box, with a submit and cancel button under it. Compare how much effort it took to add these elements with how you would normally make forms. I hope you are already seeing how quick this is!</p>
<p>Now let's try submitting the form:</p>
<p>[insert screenshot of boom]</p>
<p>We have not specified the function that gets run when the form is submitted. This function has the name <tt class="docutils literal"><span class="pre">[formname]_submit</span></tt>, and once it is done it should somehow redirect the user to another page (or redirect back to the same page if you wish, but it must be a redirect so that the form state is cleared), or exit the script. For now we will just show a success page:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">blogpost</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Post Title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">blogpost_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#008000;" title="php/php5/symbol">&lt;&lt;&lt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/start">EOF
</span><span style="color:#f00;" title="php/php5/heredoc">&lt;p&gt;Congratulations! New post entered. &lt;a href=&quot;&quot;&gt;Back to enter another one&lt;/a&gt;...&lt;/p&gt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/end">
EOF</span><span style="color:#008000;" title="php/php5/symbol">;
</span>    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>Please pardon my terrible HTML, this is only an example :). Now, when you submit the form:</p>
<p>[screenshot of success]</p>
<p>That's much better. Of course, the submit function should have inserted the blog post into the database before displaying this message, but I'll leave that detail as an exercise for the reader.</p>
<p>But what about the cancel button?</p>
<p>[screenshot of cancel boom]</p>
<p>Not so great, luckily Pieforms tells you what you need to do to fix that. While we're at it, let's add the textarea for the post content:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">blogpost</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Post Title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">content</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">textarea</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Content</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">goto</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">_SERVER</span><span style="color:#008000;" title="php/php5/symbol">[</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">SCRIPT_NAME</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">]</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">blogpost_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#008000;" title="php/php5/symbol">&lt;&lt;&lt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/start">EOF
</span><span style="color:#f00;" title="php/php5/heredoc">&lt;p&gt;Congratulations! New post entered. &lt;a href=&quot;&quot;&gt;Back to enter another one&lt;/a&gt;...&lt;/p&gt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/end">
EOF</span><span style="color:#008000;" title="php/php5/symbol">;
</span>    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>[insert screenshot of form]</p>
<p>You will get the result above both when you view and cancel the form. Of course, your cancel button could redirect elsewhere, or put a message in the session that is displayed on the next page, using the cancel function <tt class="docutils literal"><span class="pre">[formname]_cancel_submit</span></tt> rather than <tt class="docutils literal"><span class="pre">'goto'</span></tt> on the element.</p>
<p>So now all that remains is the category multiple select and the date for when the post will be published. These should be in a fieldset:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">blogpost</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Post Title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">content</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">textarea</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Content</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">optional</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>        <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">fieldset</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>       <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Advanced Options...</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">collapsable</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">collapsed</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">categories</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">select</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>    <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Categories</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">multiple</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">size</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#11e;" title="php/php5/num/int">5</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">values</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                        <span style="color:#11e;" title="php/php5/num/int">1</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Personal</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">2</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Rants</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">3</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Politics</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">4</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Religion</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">5</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Science</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">6</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Arts</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
                    <span style="color:#008000;" title="php/php5/symbol">)</span>
                <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">publishdate</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">date</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Publish Date</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
                <span style="color:#008000;" title="php/php5/symbol">)</span>
            <span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">goto</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">_SERVER</span><span style="color:#008000;" title="php/php5/symbol">[</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">SCRIPT_NAME</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">]</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">blogpost_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#008000;" title="php/php5/symbol">&lt;&lt;&lt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/start">EOF
</span><span style="color:#f00;" title="php/php5/heredoc">&lt;p&gt;Congratulations! New post entered. &lt;a href=&quot;&quot;&gt;Back to enter another one&lt;/a&gt;...&lt;/p&gt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/end">
EOF</span><span style="color:#008000;" title="php/php5/symbol">;
</span>    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>[insert screenshot]</p>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id4" id="adding-a-touch-of-class" name="adding-a-touch-of-class">Adding a Touch of Class</a></h2>
<p>Now the whole form is layed out, including the collapsable fieldset. Cool! But we are not finished yet. The form has no rules attached to it (other than a hidden rule on the multiselect box to automatically check that the submitted value is in the array of values), and could be improved with a bit of javascript love. On the rule side, let's make the title and content of the post required and the publish date be later than the current time. For javascript improvement, we can make the textarea resizable and auto focus the title element on page load.</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">blogpost</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">autofocus</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Post Title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">rules</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">required</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">content</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">textarea</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Content</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">rules</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">required</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">resizable</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">optional</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>        <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">fieldset</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>       <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Advanced Options...</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">collapsable</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">collapsed</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">categories</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">select</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>    <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Categories</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">multiple</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">size</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#11e;" title="php/php5/num/int">5</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">values</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                        <span style="color:#11e;" title="php/php5/num/int">1</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Personal</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">2</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Rants</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">3</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Politics</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">4</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Religion</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">5</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Science</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                        <span style="color:#11e;" title="php/php5/num/int">6</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Arts</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
                    <span style="color:#008000;" title="php/php5/symbol">)</span>
                <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">publishdate</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">date</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
                    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Publish Date</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
                <span style="color:#008000;" title="php/php5/symbol">)</span>
            <span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">goto</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">_SERVER</span><span style="color:#008000;" title="php/php5/symbol">[</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">SCRIPT_NAME</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">]</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">blogpost_validate</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <span style="color:#a1a100;" title="php/php5/keyword">if</span> <span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">[</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">publishdate</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">]</span> <span style="color:#008000;" title="php/php5/symbol">&amp;</span><span style="color:#008000;" title="php/php5/symbol">&amp;</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">[</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">publishdate</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">]</span> <span style="color:#008000;" title="php/php5/symbol">&lt;</span> <a href="http://www.php.net/time"><span style="color:#006;" title="php/php5/function">time</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
        <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">-&gt;</span><span style="color:#933;" title="php/php5/oodynamic">set_error</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">publishdate</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Sorry, your publish date must be in the future</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <span style="color:#008000;" title="php/php5/symbol">}</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">blogpost_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#008000;" title="php/php5/symbol">&lt;&lt;&lt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/start">EOF
</span><span style="color:#f00;" title="php/php5/heredoc">&lt;p&gt;Congratulations! New post entered. &lt;a href=&quot;&quot;&gt;Back to enter another one&lt;/a&gt;...&lt;/p&gt;</span><span style="color:#006;font-weight:bold;" title="php/php5/heredoc/end">
EOF</span><span style="color:#008000;" title="php/php5/symbol">;
</span>    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>Not too much added, and pretty much everything we wanted is implemented. The title and content are now required - try submitting the form without them set. There's no easy rule for checking that a value is greater than another just yet, so we added a 'validate' function which sets an error on the form if the publish date is not in the future. It took one line to make the textarea resizable, and just one more to make the title element focus on page load. Note that we specified 'autofocus' to be <strong>true</strong> - this means that the first element in the form will be focussed on page load. You can specify an element by name if you want that particular element to be focussed on page load.</p>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id5" id="the-finishing-touches" name="the-finishing-touches">The Finishing Touches</a></h2>
<p>Programatically, the form is done (except for any actualy logic to save the data somewhere). Now all you need it a bit of CSS magic, and you're done!</p>
<p>[insert CSS code here]</p>
<p>[insert screenshot here]</p>
<p>From zero to form in very short order - when you get good at writing forms and Pieforms is already integrated into your software, the above form will be very quick indeed to create.</p>
<p>Now let's move on to another form, this time one that will have a bit more of an 'AJAX feel'.</p>
</div>
</div>
<div class="section">
<h1><a class="toc-backref" href="#id6" id="a-form-with-wings" name="a-form-with-wings">A Form With Wings</a></h1>
<p>Happy with the form you made in the previous section, you now move on to your next task - a settings page for the admin section of your blog software. The form is for managing some global information about file uploads. As you will see, a little bit of Pieforms magic makes this form trivial to write.</p>
<div class="section">
<h2><a class="toc-backref" href="#id7" id="overview" name="overview">Overview</a></h2>
<p>The form will have the following fields for an administrator to fill out:</p>
<ul class="simple">
<li>A global toggle, for whether file uploading is enabled or disabled</li>
<li>A text field, in which the user can put the path to the <tt class="docutils literal"><span class="pre">file</span></tt> binary, used for checking the file type of uploaded files</li>
<li>An element for inputting the quota that each user is allowed</li>
</ul>
<p>Let's get started with the boilerplate:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">filesettings</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">filesettings_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;pre&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/print_r"><span style="color:#006;" title="php/php5/function">print_r</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;/pre&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;a href=&quot;&quot;&gt;Back to try again&lt;/a&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>Now to add the elements:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">filesettings</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">enabled</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">checkbox</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">File Uploading Enabled?</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">defaultvalue</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pathtofile</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Path to the &quot;file&quot; command</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">defaultvalue</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">/usr/bin/file</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">quota</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">bytes</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">User Quota</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">defaultvalue</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#11e;" title="php/php5/num/int">10</span> <span style="color:#008000;" title="php/php5/symbol">*</span> <span style="color:#11e;" title="php/php5/num/int">1024</span> <span style="color:#008000;" title="php/php5/symbol">*</span> <span style="color:#11e;" title="php/php5/num/int">1024</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">filesettings_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;pre&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/print_r"><span style="color:#006;" title="php/php5/function">print_r</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;/pre&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;a href=&quot;&quot;&gt;Back to try again&lt;/a&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>Nothing too dramatic there... but what about that 'bytes' element?</p>
<p>The 'bytes' element is the first example of how <strong>elements do not have to correspond to HTML form widgets</strong>. In fact, the 'bytes' element is made up of both a (short) text box and a select dropdown. Users can input the quota in either bytes, kilobytes or megabytes using this element, depending on what suits them.</p>
<p>This form was not hard to make, given the previous example, but it does seem like such a waste to have to do a whole round trip to the server to save the values each time. Lets make this form a 'jsform', for speed.</p>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id8" id="making-a-form-work-quickly" name="making-a-form-work-quickly">Making a Form Work Quickly</a></h2>
<p>Making the form submit via a hidden iframe takes one more line of code in the form definition, and a small change to the submit function:</p>
<pre style="background-color:#ffc;border:1px solid #cc9;"><span style="font-weight:bold;color:#000;" title="php/php5/start">&lt;?php</span>

<a href="http://www.php.net/require_once"><span style="color:#a1a100;" title="php/php5/keyword">require_once</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pieform.php</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#600;font-weight:bold;" title="php/php5/functioncall">pieform</span><span style="color:#008000;" title="php/php5/symbol">(</span><a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">name</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>     <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">filesettings</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">method</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">jsform</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>   <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span><span style="color:#008000;" title="php/php5/symbol">,</span>
    <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">elements</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">enabled</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>  <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">checkbox</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">File Uploading Enabled?</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">defaultvalue</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="font-weight:bold;color:#000;" title="php/php5/constant">true</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">pathtofile</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">text</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Path to the &quot;file&quot; command</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">defaultvalue</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">/usr/bin/file</span><span style="color:#f00;" title="php/php5/single_string/end">'</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">quota</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">bytes</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">title</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">User Quota</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">defaultvalue</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#11e;" title="php/php5/num/int">10</span> <span style="color:#008000;" title="php/php5/symbol">*</span> <span style="color:#11e;" title="php/php5/num/int">1024</span> <span style="color:#008000;" title="php/php5/symbol">*</span> <span style="color:#11e;" title="php/php5/num/int">1024</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">,</span>
        <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submit</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">type</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">submitcancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span>
            <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">value</span><span style="color:#f00;" title="php/php5/single_string/end">'</span> <span style="color:#008000;" title="php/php5/symbol">=</span><span style="color:#008000;" title="php/php5/symbol">&gt;</span> <a href="http://www.php.net/array"><span style="color:#a1a100;" title="php/php5/keyword">array</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Enter New Post</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Cancel</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span>
        <span style="color:#008000;" title="php/php5/symbol">)</span>
    <span style="color:#008000;" title="php/php5/symbol">)</span>
<span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>

<span style="color:#a1a100;" title="php/php5/keyword">function</span> <span style="color:#600;" title="php/php5/functionname">filesettings_submit</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">Pieform</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
    <span style="color:#a1a100;" title="php/php5/keyword">if</span> <span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">-&gt;</span><span style="color:#933;" title="php/php5/oodynamic">get_property</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">jsform</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">)</span> <span style="color:#008000;" title="php/php5/symbol">{</span>
        <span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">form</span><span style="color:#008000;" title="php/php5/symbol">-&gt;</span><span style="color:#933;" title="php/php5/oodynamic">json_reply</span><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#000;" title="php/php5">PIEFORM_OK</span><span style="color:#008000;" title="php/php5/symbol">,</span> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">Form saved successfully</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <span style="color:#008000;" title="php/php5/symbol">}</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;pre&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/print_r"><span style="color:#006;" title="php/php5/function">print_r</span></a><span style="color:#008000;" title="php/php5/symbol">(</span><span style="color:#33f;" title="php/php5/varstart">$</span><span style="color:#33f;" title="php/php5/var">values</span><span style="color:#008000;" title="php/php5/symbol">)</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;/pre&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/echo"><span style="color:#a1a100;" title="php/php5/keyword">echo</span></a> <span style="color:#f00;" title="php/php5/single_string/start">'</span><span style="color:#f00;" title="php/php5/single_string">&lt;a href=&quot;&quot;&gt;Back to try again&lt;/a&gt;</span><span style="color:#f00;" title="php/php5/single_string/end">'</span><span style="color:#008000;" title="php/php5/symbol">;</span>
    <a href="http://www.php.net/exit"><span style="color:#a1a100;" title="php/php5/keyword">exit</span></a><span style="color:#008000;" title="php/php5/symbol">;</span>
<span style="color:#008000;" title="php/php5/symbol">}</span>

<span style="font-weight:bold;color:#000;" title="php/php5/end">?&gt;</span></pre><p>Give it a try. What works, and what doesn't?</p>
<p>All that was added was the one line, <tt class="docutils literal"><span class="pre">'jsform'</span> <span class="pre">=&gt;</span> <span class="pre">true</span></tt> in the form definition, and the one if statement in the submit function. But behind the scenes, the whole submission process of the form as changed. Now, when you click the submit button, the following things happen:</p>
<ul class="simple">
<li>A hidden &lt;iframe&gt; is created</li>
<li>The form target is changed so that the form submits to the newly created &lt;iframe&gt;</li>
<li>A javascript function is created that will handle the reply, when it arrives</li>
<li>The form is submitted</li>
<li>The reply that comes back to the &lt;iframe&gt; calls the function registered to handle the reply</li>
</ul>
<p>You send a reply to a jsform using the <tt class="docutils literal"><span class="pre">$form-&gt;json_reply</span></tt> method. Pretty much all of the time, the first parameter will be <tt class="docutils literal"><span class="pre">PIEFORM_OK</span></tt>. The second parameter contains data that you can send back to the application.</p>
<p>Speaking of that data - why did you not see a happy success message like you were expecting? Well, Pieforms may be pretty smart, but it's not the next Einstein. You haven't told it <em>how</em> to deal with this data. You need to add one more line to the form definition, and write a javascript function:</p>
<p>[insert example here]</p>
<p>And this is the result, when you submit the form:</p>
<p>[insert screenshot here]</p>
<p>Excellent! There's only one little issue now. Because you're a great believer in not using tables where not required, you want to change how the form is layed out. All you need to do is add one line to change the renderer:</p>
<p>[insert example here]</p>
<p>[insert screenshot here]</p>
<p>Pieforms comes with a few renderers by default, they're in the <tt class="docutils literal"><span class="pre">pieform/renderers</span></tt> directory. Try them all, and see how the layout of your form changes.</p>
</div>
</div>
<div class="section">
<h1><a class="toc-backref" href="#id9" id="conclusion" name="conclusion">Conclusion</a></h1>
<p>As you can see, Pieforms makes it really easy to make your own forms in a hurry, with not much effort. It's easy to write the forms, and easy to gain some advanced functionality quite quickly. All of this is possible because there is a lot of structure to how forms work - elements, renderers and rules. As long as you stay within those concepts, you'll have no trouble in using Pieforms in your applications.</p>
<p>It is fully expected that Pieforms will not provide all of the elements you will need for your application, nor all of the renderers or rules that you require, as your application will likely have unique requirements. Now you are ready to move on to finding out more about the plugin APIs, so that you can write your own.</p>
<p><div id="breadcrumbs"><a href="http://pieforms.sourceforge.net/">Pieforms Home</a> &raquo; <a href="../">Documentation Home</a> &raquo; <a href="">Pieforms Usage</a></div></p>
</div>
</div>

<div id="footer">Pieforms by <a href="http://nigel.mcnie.name/">Nigel McNie</a> and <a href="http://pieforms.sourceforge.net/about#authors">others</a>,
&copy; 2006 Catalyst IT Ltd. Pieforms is released under the <a href="http://gnu.org/licences/gpl.html">GNU GPL</a></div>
</body>
</html>
Return current item: Pieforms