wiki:Documentation/Parser

Version 2 (modified by schst, 8 years ago) (diff)

--

TracNav(TracNav/TOC)?

patForms Parser

The patForms_Parser allows you to embedd XML-tags that represent a form and its elements inside HTML files. The parser will then extract the form definition from this file and create a new renderer which contains the plain HTML document and placeholders for the element. This way a designer is able to create a form, add some simple validation rules and has full control over the layout of the resulting page and the styles of the elements.

The developer only needs to parse the file, instead of using the factory methods and then can continue working with the form as if he had created it using PHP.

Basic form template

A form template can be any HTML or other text-based file that includes form elements in the form namespace patForms:

<patForms:Form name="myform">
<table border="0" cellpadding="2" cellspacing="0">
  <tr>
    <td>Username*</td>
    <td>
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><patForms:String name="username" required="yes" description="Please enter your name here" size="8" maxlength="8" accesskey="U" /></td>
          <td>&nbsp;Password*&nbsp;</td>
          <td><patForms:String name="password" type="password" required="yes" size="6" maxlength="6" accesskey="P" /></td>
          <td>&nbsp;Age*&nbsp;</td>
          <td><patForms:Number name="age" required="yes" size="2" max="22" min="18" default="" accesskey="A" /></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>Comments</td>
    <td colspan="7"><patForms:Text name="comments" required="no" cols="68" rows="3" accesskey="C" /></td>
  </tr>
</table>
</patForms:Form>