cvs: peardoc /en/package/html html-quickform.xml /en/package/html/html-quickform html-quickform-renderer-quickhtml.xml
/en/package/html/html-quickform/html-quickform-renderer-quickhtml elementtohtml.xml html_quickform_renderer_quickhtml.xml tohtml.xml

From: Date: Mon, 25 Aug 2003 16:38:54 +0000
Subject: cvs: peardoc /en/package/html html-quickform.xml /en/package/html/html-quickform html-quickform-renderer-quickhtml.xml
/en/package/html/html-quickform/html-quickform-renderer-quickhtml elementtohtml.xml html_quickform_renderer_quickhtml.xml tohtml.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-1397@lists.php.net to get a copy of this message
jrust Mon Aug 25 12:38:54 2003 EDT Added files: /peardoc/en/package/html/html-quickform html-quickform-renderer-quickhtml.xml /peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml elementtohtml.xml html_quickform_renderer_quickhtml.xml tohtml.xml Modified files: /peardoc/en/package/html html-quickform.xml Log: Adding documentation for QuickForm's QuickHtml renderer

Index: peardoc/en/package/html/html-quickform.xml diff -u peardoc/en/package/html/html-quickform.xml:1.7 peardoc/en/package/html/html-quickform.xml:1.8 --- peardoc/en/package/html/html-quickform.xml:1.7 Mon Aug 11 11:50:01 2003 +++ peardoc/en/package/html/html-quickform.xml Mon Aug 25 12:38:52 2003 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <sect1 id="package.html.html-quickform"> <title>HTML_QuickForm</title> <para> @@ -160,6 +160,11 @@ &package.html.html-quickform.html-quickform-renderer-itstatic.html-quickform-renderer-itstatic; &package.html.html-quickform.html-quickform-renderer-itstatic.seterrortemplate; &package.html.html-quickform.html-quickform-renderer-itstatic.setrequiredtemplate; + +&package.html.html-quickform.html-quickform-renderer-quickhtml; +&package.html.html-quickform.html-quickform-renderer-quickhtml.html-quickform-renderer-quickhtml; +&package.html.html-quickform.html-quickform-renderer-quickhtml.tohtml; +&package.html.html-quickform.html-quickform-renderer-quickhtml.elementtohtml; </sect3> <sect3 id="package.html.html-quickform.output.renderer-doc"> Index: peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml.xml +++ peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml.xml <?xml version="1.0"?> <!-- $Revision: 1.1 $ --> <refentry id="package.html.html-quickform.html-quickform-renderer-quickhtml"> <refnamediv> <refname> <classname>HTML_QuickForm_Renderer_QuickHtml</classname> </refname> <refpurpose>Render form elements into HTML in an easy and flexible manner</refpurpose> </refnamediv> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.desc"> &title.desc; <para> This renderer has three main distinctives: an easy way to create custom-looking forms, the ability to separate the creation of form elements from their display, and being able to use QuickForm in widget-based template systems. </para> <para> All of the renderers allow you to create a custom-looking form. However, unlike the default renderer, QuickHtml is solely for creating custom forms and has the additional benefits discussed below. </para> <para> It is often desirable to separate the creation of form elements and their accompanying rules from their actual display on a page. For example, in the MVC design pattern it may be useful to create the form elements and their rules in the Model classes which control how the submitted data will be saved (field lengths, allowed characters, etc.), but leave the rendering of those form elements to the View classes which only care about how to make the page look a certain way. </para> <para> A widget is a chunk of re-usable html which can be used with other widgets to create a webpage. Any template system which supports widgets (and nearly all do) can be used with QuickHtml. An example widget may consist of a table with reserved places for the form elements. The form elements would be rendered into those places and then the form tags, any remaining form elements (such as hidden elements), and any accompanying javascript for validation would be wrapped around the table widget. </para> </refsect1> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.usage"> <title>Usage example</title> <para> The following is an example usage of the QuickHtml renderer. The "template" system we use is just a simple html widget in which the form elements are placed, but it could be replaced with a more complex template system. A more complex usage example is in <filename class="directory">docs/renderers/QuickHtml_example.php</filename> <example> <title>QuickHtml renderer usage</title> <programlisting role="php"><![CDATA[ <?php require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/Renderer/QuickHtml.php'; // Create form elements and renderer $form =& new HTML_QuickForm('tmp_form','POST'); $renderer =& new HTML_QuickForm_Renderer_QuickHtml(); $form->addElement('text','tmp_text',null,array('size' => 10)); // Create a hidden element. Note how we don't render it explicitly, // rather we let QuickHtml render it for us at the beginning of the form. $form->addElement('hidden','tmp_hidden'); // Create 2 radio elements. Note how we have to give a value when rendering // them since that is the only way to tell them apart. $form->addElement('radio','tmp_radio',null,null,'Y'); $form->addElement('radio','tmp_radio',null,null,'N'); // Create a group with a rule $text = array(); $text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 3)); $text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 4)); $text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 3)); $form->addGroup($text, 'tmp_phone', null, '-'); $form->addRule('tmp_phone','Phone number cannot be empty.','required',null,'client'); // Do the magic of creating the form. NOTE: order is important here: this must // be called after creating the form elements, but before rendering them. $form->accept($renderer); // Create a very basic template for our form $html_template = ' <div style="text-align: center;">%phoneNumber%</div> <div style="text-align: left;">Yes: %radioElementYes% No: %radioElementNo%</div>'; // Interpolate the form elements into our template $html_template = str_replace('%phoneNumber%', $renderer->elementToHtml('tmp_phone')); $html_template = str_replace('%radioElementYes%', $renderer->elementToHtml('tmp_radio', 'Y')); $html_template = str_replace('%radioElementNo%', $renderer->elementToHtml('tmp_radio', 'N')); // The form tags, javascript, and hidden element will be wrapped around // our html template echo $renderer->toHtml($html_template); ?> ]]></programlisting></example> </para> </refsect1> </refentry> <!-- 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-executeMultiple-attributes:t sgml-indent-step:1 sgml-indent-data:t 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 --> Index: peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml/elementtohtml.xml +++ peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml/elementtohtml.xml <?xml version="1.0"?> <!-- $Revision: 1.1 $ --> <refentry id="package.html.html-quickform.html-quickform-renderer-quickhtml.elementtohtml"> <refnamediv> <refname>HTML_QuickForm_Renderer_QuickHtml::elementToHtml()</refname> <refpurpose>Renders a specific form element into HTML</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> require_once 'HTML/QuickForm/Renderer/QuickHtml.php'; </funcsynopsisinfo> <funcprototype> <funcdef>string <function>HTML_QuickForm_Renderer_QuickHtml::elementToHtml</function></funcdef> <paramdef>string <parameter>$elementName</parameter></paramdef> <paramdef>string <parameter><optional>$elementValue</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.elementtohtml.desc"> &title.desc; <para>Returns the HTML generated for a specific form element and marks that element as rendered.</para> </refsect1> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.elementtohtml.param"> &title.param; <para> <variablelist> <varlistentry> <term> <parameter>$elementName</parameter> </term> <listitem> <para> The name of the form element that is being rendered. </para> </listitem> </varlistentry> <varlistentry> <term> <parameter>$elementValue</parameter> </term> <listitem> <para> The value given to the form element. This is only useful for elements that have the same name (such as a radio button), and can only be told apart based on the value assigned to them. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.elementtohtml.throws"> &title.throws; <para><emphasis>throws</emphasis> no exceptions thrown </para> </refsect1> </refentry> <!-- 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 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 --> Index: peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml/html_quickform_renderer_quickhtml.xml +++ peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml/html_quickform_renderer_quickhtml.xml <?xml version="1.0"?> <!-- $Revision: 1.1 $ --> <refentry id="package.html.html-quickform.html-quickform-renderer-quickhtml.html-quickform-renderer-quickhtml"> <refnamediv> <refname>constructor HTML_QuickForm_Renderer_QuickHtml::HTML_QuickForm_Renderer_QuickHtml()</refname> <refpurpose>Constructor</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> require_once 'HTML/QuickForm/Renderer/QuickHtml.php'; </funcsynopsisinfo> <funcprototype> <funcdef>void <function>HTML_QuickForm_Renderer_QuickHtml::HTML_QuickForm_Renderer_QuickHtml</function></funcdef> <void /> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.html-quickform-renderer-quickhtml.desc"> &title.desc; <para>The constructor for HTML_QuickForm_Renderer_QuickHtml().</para> </refsect1> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.html-quickform-renderer-quickhtml.throws"> &title.throws; <para><emphasis>throws</emphasis> no exceptions thrown</para> </refsect1> </refentry> <!-- 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 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 --> Index: peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml/tohtml.xml +++ peardoc/en/package/html/html-quickform/html-quickform-renderer-quickhtml/tohtml.xml <?xml version="1.0"?> <!-- $Revision: 1.1 $ --> <refentry id="package.html.html-quickform.html-quickform-renderer-quickhtml.tohtml"> <refnamediv> <refname>HTML_QuickForm_Renderer_QuickHtml::toHtml()</refname> <refpurpose>Returns the HTML</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> require_once 'HTML/QuickForm/Renderer/QuickHtml.php'; </funcsynopsisinfo> <funcprototype> <funcdef>string <function>HTML_QuickForm_Renderer_QuickHtml::toHtml</function></funcdef> <paramdef>string <parameter><optional>$data</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.tohtml.desc"> &title.desc; <para>Returns the HTML generated for the form.</para> </refsect1> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.tohtml.param"> &title.param; <para><variablelist><varlistentry><term> <parameter>$data</parameter> </term><listitem><para> Any html to put inside the form tags. This would normally be the html template into which you have rendered the form elements. </para></listitem></varlistentry></variablelist></para> </refsect1> <refsect1 id="package.html.html-quickform.html-quickform-renderer-quickhtml.tohtml.throws"> &title.throws; <para><emphasis>throws</emphasis> no exceptions thrown </para> </refsect1> </refentry> <!-- 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 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 -->
« previous php.pear.doc (#1397) next »