Location: PHPKode > scripts > Form Builder > form-builder/examples/attaching_buttons.php
<?
/*Include Form Class*/
include("../class.form.php");
include("../../utility.php");

if(!isset($cmd))
	$cmd = "";

if($cmd == "submit")
{
	/*Handles Form Post*/
	echo("<pre>");
	print_r($_POST);
	echo("</pre>");
	exit();
}

if($cmd == "")
{
	?>
	<html>
		<head></head>
		<body>
			<h2 style="text-align: center; margin: 0; padding: 0;">Form Builder Class - Examples</h2>
			<h5 style="text-align: center; margin: 0; padding: 0;"><span style="padding-right: 10px;">Author: Andrew Porterfield</span><span style="padding-right: 10px;">Released: April 24, 2009</span><span>Version: 0.4.0<span></h5>
			<a href="../index.html">Back to Project Home Page</a>
			<p><b>Attaching Buttons</b> - This example demonstrates how buttons are handled within the class.
			<?

			$form = new form();
			$form->setAttributes(array(
				"tableAttributes" => array("width" => "400"),
			));

			$form->addHidden("cmd", "submit");
			$form->addTextbox("Textbox:", "field0");
			$form->addSelectbox("Selectbox:", "field1", "", array("" => "--Select an Option--", "option1" => "Option 1", "option2" => "Option 2"));
			$form->addCheckbox("Checkbox:", "field2", "", array("option1" => "Option 1"));

			//Add Standard Submit Button
			$form->addButton();

			//Add Non-Submit Button W/OnClick Event
			$form->addButton("php.net", "button", array("onclick" => "window.location = \"http://www.php.net\";"));

			/*
			If your system has a utility in place for dynamically generating button images, you will want to utilize the phpFunction, phpParams, wrapLink, and hrefAttributes parameters.  A sample is provided below of what this call might look like.  View the source of class.form.php to learn more about these parameters.
			$form->addButton("", "", array("phpFunction" => "RenderDynamicButton", "phpParams" => array("param1","param2"), "wrapLink" => 1, "linkAttributes" => array("href" => "http://www.php.net/")));
			*/

			//Render Form HTML
			$form->render();
			?>
			<a href="../index.html">Back to Project Home Page</a>
		</body>
	</html>
	<?
}
?>

Return current item: Form Builder