mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
114 lines
3.5 KiB
XML
114 lines
3.5 KiB
XML
![]() |
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
|
<!-- $Revision: 1.1 $ -->
|
||
|
<chapter id="features.xforms">
|
||
|
<title>Dealing with XForms</title>
|
||
|
<para>
|
||
|
<ulink url="&url.xforms;">XForms</ulink> defines a variation on traditional
|
||
|
webforms which allows them to be used on a wider variety of platforms and
|
||
|
browsers or even non-traditional media such as PDF documents.
|
||
|
</para>
|
||
|
<para>
|
||
|
The first key difference in XForms is how the form is sent to the client.
|
||
|
<ulink url="&url.xforms.htmlauthors;">XForms for HTML Authors</ulink>
|
||
|
contains a detailed description of how to create XForms, for the purpose
|
||
|
of this tutorial we'll only be looking at a simple example.
|
||
|
</para>
|
||
|
<example>
|
||
|
<title>A simple XForms search form</title>
|
||
|
<programlisting role="html">
|
||
|
<![CDATA[
|
||
|
<h:html xmlns:h="http://www.w3.org/1999/xhtml"
|
||
|
xmlns="http://www.w3.org/2002/xforms">
|
||
|
<h:head>
|
||
|
<h:title>Search</h:title>
|
||
|
<model>
|
||
|
<submission action="http://example.com/search"
|
||
|
method="post" id="s"/>
|
||
|
</model>
|
||
|
</h:head>
|
||
|
<h:body>
|
||
|
<h:p>
|
||
|
<input ref="q"><label>Find</label></input>
|
||
|
<submit submission="s"><label>Go</label></submit>
|
||
|
</h:p>
|
||
|
</h:body>
|
||
|
</h:html>
|
||
|
]]>
|
||
|
</programlisting>
|
||
|
</example>
|
||
|
<para>
|
||
|
The above form displays a text input box (named <parameter>q</parameter>),
|
||
|
and a submit button. When the submit button is clicked, the form will be
|
||
|
sent to the page referred to by <literal>action</literal>.
|
||
|
</para>
|
||
|
<para>
|
||
|
Here's where it starts to look different from your web application's point
|
||
|
of view. In a normal HTML form, the data would be sent as
|
||
|
<literal>application/x-www-form-urlencoded</literal>, in the XForms world
|
||
|
however, this information is sent as XML formatted data.
|
||
|
</para>
|
||
|
<para>
|
||
|
If you're choosing to work with XForms then you probably want that data as
|
||
|
XML, in that case, look in <variable>$HTTP_RAW_POST_DATA</variable> where
|
||
|
you'll find the XML document generated by the browser which you can pass
|
||
|
into your favorite XSLT engine or document parser.
|
||
|
</para>
|
||
|
<para>
|
||
|
If you're not interrested in formatting and just want your data to be loaded
|
||
|
into the traditional <variable>$_POST</variable> variable, you can instruct
|
||
|
the client browser to send it as <literal>application/x-www-form-urlencoded</literal>
|
||
|
by changing the <parameter>method</parameter> attribute to
|
||
|
<emphasis>urlencoded-post</emphasis>.
|
||
|
</para>
|
||
|
<example>
|
||
|
<title>Using an XForm to populate <variable>$_POST</variable></title>
|
||
|
<programlisting role="html">
|
||
|
<![CDATA[
|
||
|
<h:html xmlns:h="http://www.w3.org/1999/xhtml"
|
||
|
xmlns="http://www.w3.org/2002/xforms">
|
||
|
<h:head>
|
||
|
<h:title>Search</h:title>
|
||
|
<model>
|
||
|
<submission action="http://example.com/search"
|
||
|
method="urlencoded-post" id="s"/>
|
||
|
</model>
|
||
|
</h:head>
|
||
|
<h:body>
|
||
|
<h:p>
|
||
|
<input ref="q"><label>Find</label></input>
|
||
|
<submit submission="s"><label>Go</label></submit>
|
||
|
</h:p>
|
||
|
</h:body>
|
||
|
</h:html>
|
||
|
]]>
|
||
|
</programlisting>
|
||
|
</example>
|
||
|
<note>
|
||
|
<simpara>
|
||
|
As of this writing, many browsers do not support XForms.
|
||
|
Check your browser version if the above examples fails.
|
||
|
</simpara>
|
||
|
</note>
|
||
|
</chapter>
|
||
|
|
||
|
<!-- Keep this comment at the end of the file
|
||
|
Local variables:
|
||
|
mode: sgml
|
||
|
sgml-omittag:t
|
||
|
sgml-shorttag:t
|
||
|
sgml-minimize-attributes:nil
|
||
|
sgml-always-quote-attributes:t
|
||
|
sgml-indent-step:1
|
||
|
sgml-indent-data:t
|
||
|
indent-tabs-mode:nil
|
||
|
sgml-parent-document:nil
|
||
|
sgml-default-dtd-file:"../../manual.ced"
|
||
|
sgml-exposed-tags:nil
|
||
|
sgml-local-catalogs:nil
|
||
|
sgml-local-ecat-files:nil
|
||
|
End:
|
||
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
|
vim: et tw=78 syn=sgml
|
||
|
vi: ts=1 sw=1
|
||
|
-->
|