Location: PHPKode > scripts > AEYNIAS Framework > aeynias-framework/aeynias_framework/documentation/form_class_usage.txt
<?php

//To start making a form:
$my_form= new make_form(string $action, string $method = 'POST');
// $action = the URL for the form to go to when subbmitted same as the ACTION="" in HTML
// $method = The method for the form, either POST or GET same as METHOD="" in HTML... Defaults to POST if not given.


// Functions of make_form()

insert_input(string $text, string $name, string $default = null, string $required=0, string $custom_error = null);
// Purpose: to make a normal text input
// $text = The text displayed next to the form field.
// $name = The name of the item, same as NAME="" in HTML
// $default = The text inside of the VALUE attribute. (Will be overriden on post by what the user already put in there, for convience)
// $required = TRUE/FALSE or 0/1, wether or not the form element is required (To be used with the post_form class)
// $custom_error = Override the default error when left blank.


insert_submit($value = 'Submit',$name = 'submit');
// Purpose: To insert a submit button.
// $value = The text of the Submit Button, same as VALUE="" in HTML
// $name = The name of the submit button, same as NAME="" in HTML

insert_hidden($value,$name,$required=1,$error_msg = null);
// Purpose: Inserts a hidden form element.
// $value = The value of the form element, the same as VALUE="" in HTML
// $name = The name of the form element, same as NAME="" in HTML
// $required = Wether or not this field is required... I would hope it would have a value, since you set it..
// $error_msg = The error message if it has no value.. Err, Don't think your going to use this to much.

insert_anything($html);
// Purpose: Insert anything you want to your form.
// $html = What ever the heck you want it to be! Just some HTML or Javascript or Text.. have some fun..

insert_select($text, $array,$name,$default = '',$required=1,$custom_error = '')
// Purpose: To insert a select box thingy.. Ya know <SELECT> ;)
// $text = The text beside the select.
// $array = an array of the itmes.. EG: array('Item1'=>'Value for Item1')
// $name = The name of the select.
// $default = The defualt selected item, in this example above id put 'Value for Item1' if I want it to be selected.. Even though It would be selected default anyways because its the only item...
// $required = Wether or not this item is required... TRUE/FALSE or 1/0
// $custom_error = The error to show if the value of this wasn't filled.. You can make a null value by just giving an item no value.. *GUH*


insert_password($text,$name,$required=0,$custom_error = null)
// Purpose: Ugh.. To insert a password field thingy ma-jigger..
// $text = The text next to the password field.
// $name = The name of the password field.. Same as NAME="" in HTML
// $required = Again.. Weither or not its required.. TRUE/FALSE or 1/0
// $custom_error = If its not filled, then display this error.. there is a default one if this is nulled..

insert_textarea($text,$name,$rows,$cols,$default = null,$required=0,$custom_error = null)
// Purpose: To Insert a textarea..
// $text = The text next to the textarea.
// $name = The name of the textarea
// $rows = The row count of the textarea.
// $cols = The column count of the textarea.
// $default = The default text..
// $required = Wether this is required.. True/false 1/0

get_keys();
// Purpose: To be used with post_form class.


return_form();
// Purpose: Returns the HTML of the form. IE: Puts everytthing together and sends it out to you.


//// The post_form class ////
// just look at the example, its the only way to explain it, atleast at this time of night *cough* 4 AM

$post_form = new post_form();	// Set up the post_form class.

$form = new make_form('./');	// set up the make_form class.
$form->insert_input('First Name','fname','John');	// First Name text field
$form->insert_input('Last Name','lname','Doe');		// Last name Text Field
$form->insert_password('Password','pass',1,'Dood, no password!?');	// A Password field
$form->insert_select('Gender',array('Male' => 'male' , 'Female' => 'female', 'Other' => 'other'),'gender','female');	// Persons Genders
$form->insert_textarea('About you','about','5','30');	// A textarea about section thingy..
$form->insert_submit('Let-er-rip!'); 	// And a submit button

$post_form->set_keys($form->get_keys()); // Set the FORM keys from the form to work with the POST class.. This is whats used to make sure all form fields are there..


if (isset($_POST['submit'])){		// The form has been submitted
	if ($post_form->check_form()){		// Will return true if the form has all fields and everything cheks out with no missing values.. If there are problems, they will be represented on the page using the error() function.
		// continue
		$page_text = 'so far so good..';
	}
	else $page_text = $form->return_form();		// Since the check_Form turned out false, we have to reshow the form.. All the fields have been filled with the text from before..
}
else $page_text = $form->return_form();		// Display the form becasue nothing has been done..



?>
Return current item: AEYNIAS Framework