Converting a set of pages into using formtemplate
This page show how to convert a set of pages that doesn't use formtemplate into using formtemplate
- Let's take this simple form (let's say it's called form.adp) :
<form method="post" name="news" action="item-create-2">
<table>
<tr>
<td>Title</td>
<td><input type="text" size="51" maxlength="400" id="publish_title" name=publish_title value="@publish_title@"></td>
</tr>
<tr>
<td>Lead</td>
<td><textarea id="publish_lead" name=publish_lead cols=50 rows=3>@publish_lead@</textarea></td>
</tr>
<tr>
<td>Body *</td>
<td><textarea id="publish_body" name=publish_body cols=50 rows=20 wrap=soft>@publish_body@</textarea></td>
</tr>
<tr>
<td></td>
<td align="left"><input type="submit" value="Submit"></td>
</tr>
</form>
- Now what's wrong with this form? NOTHING! Then why do we need to switch to using formtemplate? Because formtemplate
offers us several advantages.
- Let's examine how to use ad_form.
- Using formtemplate consists of two main components:
- The <formtemplate> tag in the adp page
- The ad_form procedure
- To replicate the above form using formtemplate, we do the following:
- Now we need to think about submitting to the database.
- For files that don't use ad_form, the form usually submits to a different page.
Using formtemplate eliminates this. Most pages that use formtemplate will just submit back to the same page.
One of the main advantages of submitting back to the same page is that you can get inline error messages in the form.