Location: PHPKode > projects > PHP Toolbox > apidoc/CForm.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
   <TITLE>class CForm</TITLE>
   <META NAME="GENERATOR" CONTENT="DOC++ 3.4.8">
   <LINK REL="stylesheet" TYPE="text/css" HREF="docxx.css">
</HEAD>
 <body>
<h1>PHP/Toolbox#2</h1>
<a name=top>&nbsp;</a>
<div class="navbar">
=[<a href="index.html">Contents</a>]=[<a href="HIER.html">Class Tree</a>]=[<a href="#bottom">Bottom</a>]=
</div>
<br>
In file cform.phps:<H2>class <A HREF="#DOC.DOCU">CForm</A></H2></H2><BLOCKQUOTE>The main form class.</BLOCKQUOTE>
<HR>
<H2>Documentation</H2>
<BLOCKQUOTE>The main form class.
The general CForm usage follows:
<xmp>
|	$form = new CForm(array(
|		"field_1"	=> new CControl(array(
|			"label"	=> "Field 1",
|			...
|		)),
|		"field_2"	=> new CControl(array(
|			"label"	=> "Field 2",
|			...
|		)),
|		...
|	));
|	$form->addSubmitCancel("Submit_Label", "Cancel_Label");
</xmp>
@package	PHP/Toolbox::Form</BLOCKQUOTE>

<A NAME="DOC.DOCU"></A>
<HR>

<H2>Inheritance:</H2>
<H3>CForm
- <A HREF="CSnippet.html">CSnippet</A>
</H3>
<HR>

<DL>
<P><DL>
<DT><H3>Public Fields</H3><DD><DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.15.2">ACTION</A></B>
<DD><I>Form ACTION</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.15.3">METHOD</A></B>
<DD><I>Form method.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.15.1">MODE</A></B>
<DD><I> Form MODE.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.15.4">controls</A></B>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.5">CForm</A></B>($<!1><A HREF="CForm.html#DOC.15.4">controls</A> = array()
<DD><I>Constructor.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.19">CONTROL</A></B>($name)
<DD><I> Returns control by name, eg.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.20">CONTROL_CODE</A></B>($name)
<DD><I> Returns control code by name.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.22">CONTROL_LIST_EACH</A></B>()
<DD><I> Returns next control from the list as <code>list($name, $control)</code>.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.23">CONTROL_LIST_EACH_CODE</A></B>()
<DD><I> Returns next control code from the list.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.21">CONTROL_LIST_START</A></B>()
<DD><I> Starts the control list.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.24">FORM_END</A></B>()
<DD><I> Ends the form.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.17">FORM_START</A></B>()
<DD><I> Starts the form.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.7">addControl</A></B>($name, $control)
<DD><I>Adds the control.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.6">addControls</A></B>($<!1><A HREF="CForm.html#DOC.15.4">controls</A>)
<DD><I>Adds the list of controls.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.9">addSubmitCancel</A></B>($submit=SUBMIT, $cancel=CANCEL)
<DD><I>Adds SUBMIT/CANCEL buttons.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.8">addVars</A></B>($HTTP_VARS = , $<!1><A HREF="CTextarea.html#DOC.53.1">type</A> = )
<DD><I>Adds vars from the specified array.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.18">getControlCode</A></B>($name, $control)
<DD><I> Helper method.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.11">getValue</A></B>($control)
<DD><I>Returns value from the specified control.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.12">inValue</A></B>($control, $value)
<DD><I>Control's value to input to form.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.13">outValue</A></B>($control)
<DD><I>Control's value to output from the form.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.14">outValues</A></B>()
<DD><I>Collects output values of the form.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.10">setMode</A></B>($newMode)
<DD><I>Sets the form mode.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.16">validateValue</A></B>($control)
<DD><I>Use this to override the data verification on the form level, eg.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>function <B><A HREF="#DOC.15.15">validateValues</A></B>($subform=NULL)
<DD><I>Use this to validate form data.</I>
</DL></P>

</DL>
<HR><H3>Inherited from <A HREF="CSnippet.html">CSnippet</A>:</H3>
<DL>
<P><DL>
<DT><H3>Public Fields</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif> <B>buffer</B>
<DT>
<IMG ALT="o" SRC=icon2.gif> <B>class</B>
<DT>
<IMG ALT="o" SRC=icon2.gif> <B>id</B>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>function <B>append</B>($fields)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>buffer</B>($str)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>flush</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>getExternal</B>($varName, $default = , $globalArrayName=)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>getGlobal</B>($varName, $default = )
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>getVar</B>($varName)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>qualify</B>($varName)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>reset_buffer</B>($str=)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>reset_class_vars</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>setExternal</B>($varName, $value, $globalArrayName=)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>setGlobal</B>($varName, $value)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>write</B>($str)
<DT>
<IMG ALT="o" SRC=icon2.gif>function <B>writeCode</B>($<!1><A HREF="CTextarea.html#DOC.53.3">code</A>, $eval=FALSE)
</DL></P>

</DL>
<DL>

<A NAME="MODE"></A>
<A NAME="DOC.15.1"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> MODE</B></TT>
<DD>
Form MODE.
The additional mode supported by the form core is Readonly.

<DL><DT><DT><B>See Also:</B><DD><!1><A HREF="CForm.html#DOC.15.10">setMode</A>()<BR><DD></DL><P>
<A NAME="ACTION"></A>
<A NAME="DOC.15.2"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> ACTION</B></TT>
<DD>Form ACTION
<DL><DT><DD></DL><P>
<A NAME="METHOD"></A>
<A NAME="DOC.15.3"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> METHOD</B></TT>
<DD>Form method.
GET, POST.
<DL><DT><DD></DL><P>
<A NAME="controls"></A>
<A NAME="DOC.15.4"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> controls</B></TT>
<DL><DT><DD></DL><P>
<A NAME="CForm"></A>
<A NAME="DOC.15.5"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function CForm($<!1><A HREF="CForm.html#DOC.15.4">controls</A> = array()</B></TT>
<DD>Constructor.

<DL><DT><DT><B>Parameters:</B><DD><B>array</B> - 	$<!1><A HREF="CForm.html#DOC.15.4">controls</A>	- array of controls.
<BR><B>string</B> - 	$action		- form action.
<BR><B>string</B> - 	$method		- form method.
<BR><B>array</B> - 	$<!1><A HREF="CMarkup.html#DOC.20.1">attrs</A>		- form extra <!1><A HREF="CMarkup.html#DOC.20.1">attrs</A>
<BR><DT><B>See Also:</B><DD>CSnippet::CSnippet()<BR><DD></DL><P>
<A NAME="addControls"></A>
<A NAME="DOC.15.6"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function addControls($<!1><A HREF="CForm.html#DOC.15.4">controls</A>)</B></TT>
<DD>Adds the list of controls.
@access	public.

<DL><DT><DT><B>See Also:</B><DD><!1><A HREF="CForm.html#DOC.15.7">addControl</A>().<BR><DD></DL><P>
<A NAME="addControl"></A>
<A NAME="DOC.15.7"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function addControl($name, $control)</B></TT>
<DD>Adds the control.
First the control is checked on null.
If the name is string then control is associated with this name.
Otherwise, the name field of control is used.
Otherwise, the control is added to the end of the list.

<DL><DT><DT><B>Parameters:</B><DD><B>string</B> - 	- name of the control.
<BR><B>object</B> -  <!1><A HREF="CControl.html">CControl</A>  - the control.<BR><DD></DL><P>
<A NAME="addVars"></A>
<A NAME="DOC.15.8"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function addVars($HTTP_VARS = , $<!1><A HREF="CTextarea.html#DOC.53.1">type</A> = )</B></TT>
<DD>Adds vars from the specified array.
Uses HTTP_GET_VARS and type=hidden by default.
@access	public

<DL><DT><DT><B>Parameters:</B><DD><B>string</B> -  $HTTP_VARS	- array's *name*.
<BR><B>string</B> -  $<!1><A HREF="CTextarea.html#DOC.53.1">type</A>			- <!1><A HREF="CForm.html#DOC.15.4">controls</A>' type.<BR><DD></DL><P>
<A NAME="addSubmitCancel"></A>
<A NAME="DOC.15.9"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function addSubmitCancel($submit=SUBMIT, $cancel=CANCEL)</B></TT>
<DD>Adds SUBMIT/CANCEL buttons.
Besides, it adds all work stuff.
@access	public

<DL><DT><DT><B>Parameters:</B><DD><B>string</B> - 	- name.
<BR><B>string</B> - 	- name.<BR><DD></DL><P>
<A NAME="setMode"></A>
<A NAME="DOC.15.10"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function setMode($newMode)</B></TT>
<DD>Sets the form mode.
Besides, it adds all work stuff.
@access	public

<DL><DT><DT><B>Parameters:</B><DD><B>string</B> - 	- new mode.
<BR><DT><B>Returns:</B><DD>  string	- old mode.<BR><DD></DL><P>
<A NAME="getValue"></A>
<A NAME="DOC.15.11"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function getValue($control)</B></TT>
<DD>Returns value from the specified control.
Use this to override the data handling,
e.g. to process special data formats.
@access	private

<DL><DT><DT><B>Parameters:</B><DD><B>object</B> - 	<!1><A HREF="CControl.html">CControl</A>
<BR><DT><B>Returns:</B><DD>  mixed	- value.<BR><DD></DL><P>
<A NAME="inValue"></A>
<A NAME="DOC.15.12"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function inValue($control, $value)</B></TT>
<DD>Control's value to input to form.
Use this to override the data handling,
e.g. to process special data formats.
@access	private

<DL><DT><DT><B>Parameters:</B><DD><B>object</B> -  	<!1><A HREF="CControl.html">CControl</A>
<BR><B>mixed</B> - 	- value.
<BR><DT><B>Returns:</B><DD>  mixed	- in value.<BR><DD></DL><P>
<A NAME="outValue"></A>
<A NAME="DOC.15.13"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function outValue($control)</B></TT>
<DD>Control's value to output from the form.
Use this to override the data handling,
e.g. to process special data formats.
@access	private

<DL><DT><DT><B>Parameters:</B><DD><B>object</B> -  	<!1><A HREF="CControl.html">CControl</A>
<BR><DT><B>Returns:</B><DD>  mixed	- out value.<BR><DD></DL><P>
<A NAME="outValues"></A>
<A NAME="DOC.15.14"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function outValues()</B></TT>
<DD>Collects output values of the form.
Use this to get form data as array.
@access	private

<DL><DT><DT><B>Returns:</B><DD>  array	- out values.<BR><DD></DL><P>
<A NAME="validateValues"></A>
<A NAME="DOC.15.15"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function validateValues($subform=NULL)</B></TT>
<DD>Use this to validate form data.
<code>$form->errors</code> will contain array
of <code>control-name=>error-message</code> pairs.
@access	public

<DL><DT><DT><B>Returns:</B><DD>  bool	- TRUE if no errors occured.<BR><DD></DL><P>
<A NAME="validateValue"></A>
<A NAME="DOC.15.16"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function validateValue($control)</B></TT>
<DD>Use this to override the data verification on the form level,
eg. to process special data formats.
@access	private

<DL><DT><DT><B>Parameters:</B><DD><B>object</B> -  	<!1><A HREF="CControl.html">CControl</A>
<BR><DT><B>Returns:</B><DD>  mixed	- control validation result.<BR><DD></DL><P>
<A NAME="FORM_START"></A>
<A NAME="DOC.15.17"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function FORM_START()</B></TT>
<DD>
Starts the form.
You, probably, rarely use it in a form template as it can be
made more consistent for HTML editors to insert the form tag
manually.
<DL><DT><DD></DL><P>
<A NAME="getControlCode"></A>
<A NAME="DOC.15.18"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function getControlCode($name, $control)</B></TT>
<DD>
Helper method.
Returns control with code and attributes
(in addition to conventional control's fileds):
<ul>
<li> CODE - control HTML code, like &LT;input name=... type=... etc.&GT;
<li> ERROR - the error message about the control processing.
<li> ACCEPTED - is control's value submitted and valid.
</ul>
You never use it directly.

<DL><DT><DT><B>Returns:</B><DD>  object	- control w/code.
<BR><DT><B>Since:</B><DD>#2
<DD></DL><P>
<A NAME="CONTROL"></A>
<A NAME="DOC.15.19"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function CONTROL($name)</B></TT>
<DD>
Returns control by name, eg. to render via sub-template.
You use it in a form template.

<DL><DT><DT><B>Since:</B><DD>#2
<DD></DL><P>
<A NAME="CONTROL_CODE"></A>
<A NAME="DOC.15.20"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function CONTROL_CODE($name)</B></TT>
<DD>
Returns control code by name.
You use it in a form template.

<DL><DT><DT><B>Parameters:</B><DD><B>string</B> -  $name
<BR><DT><B>Returns:</B><DD>  control
<BR><DT><B>Since:</B><DD>#2
<DT><B>See Also:</B><DD><!1><A HREF="CForm.html#DOC.15.18">getControlCode</A>()
<BR><DD></DL><P>
<A NAME="CONTROL_LIST_START"></A>
<A NAME="DOC.15.21"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function CONTROL_LIST_START()</B></TT>
<DD>
Starts the control list.
You use it in a form template.

<DL><DT><DT><B>Since:</B><DD>#2
<DD></DL><P>
<A NAME="CONTROL_LIST_EACH"></A>
<A NAME="DOC.15.22"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function CONTROL_LIST_EACH()</B></TT>
<DD>
Returns next control from the list as <code>list($name, $control)</code>.
You use it in a form template.

<DL><DT><DT><B>Since:</B><DD>#2
<DT><B>See Also:</B><DD><!1><A HREF="CForm.html#DOC.15.19">CONTROL</A>()
<BR><DD></DL><P>
<A NAME="CONTROL_LIST_EACH_CODE"></A>
<A NAME="DOC.15.23"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function CONTROL_LIST_EACH_CODE()</B></TT>
<DD>
Returns next control code from the list.
You use it in a form template.

<DL><DT><DT><B>Since:</B><DD>#2
<DT><B>See Also:</B><DD><!1><A HREF="CForm.html#DOC.15.18">getControlCode</A>()
<BR><DD></DL><P>
<A NAME="FORM_END"></A>
<A NAME="DOC.15.24"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>function FORM_END()</B></TT>
<DD>
Ends the form.
You, probably, rarely use it in a form template as it can be
made more consistent for HTML editors to insert the form tag
manually.
<DL><DT><DD></DL><P></DL>
<HR>
<DL><DT><B>Direct child classes:
</B><DD><A HREF="CDBForm.html">CDBForm</A><BR>
</DL>

<DL><DT><DD></DL><P> <a name=bottom>&nbsp;</a>
<div class="navbar">
=[<a href="index.html">Contents</a>]=[<a href="HIER.html">Class Tree</a>]=[<a href="#top">Top</a>]=
</div><HR>
<BR>
This page was generated with the help of <A HREF="http://docpp.sourceforge.net">DOC++</A>.
</BODY>
</HTML>
Return current item: PHP Toolbox