Trace:
Differences ¶
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
en:tutorials:main:news-form [2007/09/16 06:52] – created laurent | en:tutorials:main:news-form [2007/12/18 11:19] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Creation of a news form ====== | ====== Creation of a news form ====== | ||
- | A form system, jForms, is under development and will be available in Jelix 1.0 beta2. jForms deals with received data from forms server side and client side at the same time (HTML, XUL, or web services) : creation, save, data check, etc. | + | A form system, jForms, is available in Jelix, but we will see it in a next chapter. |
- | This part is more or less operational in Jelix 1.0 beta1 but remains however experimental. jForms | + | |
- | While waiting, you will have to use a more "traditional" | + | For the moment, we're going to see how to deal with forms in a "traditionnal" |
- | + | ||
- | The goal of this chapter, | + | |
Line 16: | Line 13: | ||
< | < | ||
- | <form action=" | + | <form action=" |
+ | {formurlparam ' | ||
< | < | ||
<tr> | <tr> | ||
Line 31: | Line 29: | ||
</tr> | </tr> | ||
</ | </ | ||
- | < | + | < |
+ | <a href=" | ||
</ | </ | ||
</ | </ | ||
- | Very classical, put aside the template tag {jurl}. In Jelix, you will avoid putting urls directly in the templates or the actions, for ease of maintenance and evolution reasons. The URL system of Jelix enables you to centralize all the urls in the jelix config or a urls.xml file (all depends on the URL engine used). The jUrl object and the tag {jurl} enable you to obtain a URL by giving only the name of the action and eventually the parameters. | ||
- | Here then, we state that the form will be submitted to URL of the default_createsave | + | Very classical, put aside the template tags {formurl}, {formurlparam} and {jurl}. |
+ | |||
+ | In Jelix, you will avoid putting urls directly in the templates or the actions, for ease of maintenance and evolution reasons. The URL system of Jelix enables you to centralize all the urls in the jelix config or a urls.xml file (all depends on the URL engine used). The jUrl object and the tag {jurl} enable you to obtain a URL by giving only the name of the action and eventually the parameters. | ||
+ | |||
+ | We could have used the tag {jurl} also in < | ||
+ | |||
+ | Here then, we state that the form will be submitted to URL of the default: | ||
- | Note: by default, {jurl} correctly escapes the reserved characters in HTML/XML. | + | Note: by default, {jurl}, {formurl} and {formurlparam} correctly escapes the reserved characters in HTML/XML. |
Line 58: | Line 62: | ||
< | < | ||
- | < | + | < |
</ | </ | ||
Line 65: | Line 69: | ||
===== Saving the data ===== | ===== Saving the data ===== | ||
- | As we stated in the form, we now have to create a "default_createsave" action to save the new data. | + | As we stated in the form, we now have to create a "default: |
Initially, we retrieve a record, that is filled with the data sent by the form. The URL parameters ($_GET) or posted ($_POST), are accessible via the param() method of the controllers. | Initially, we retrieve a record, that is filled with the data sent by the form. The URL parameters ($_GET) or posted ($_POST), are accessible via the param() method of the controllers. | ||
Line 86: | Line 90: | ||
<code php> | <code php> | ||
$rep = $this-> | $rep = $this-> | ||
- | $rep-> | + | $rep-> |
return $rep; | return $rep; | ||
</ | </ | ||
Line 103: | Line 107: | ||
$rep = $this-> | $rep = $this-> | ||
- | $rep-> | + | $rep-> |
return $rep; | return $rep; | ||
} | } |