Getting Started with PHP DataForm

(for version 1.0.1 or above)

After you have PHP DF installed, you need to perform next steps:

[top]

Step 1. Loading necessary DataForm classes.



// Include automatic loading of classes for proper on-demand-loading of 
// necessary DataForm classes

function __autoload($class)
{
    $class = strtolower($class);
    if(eregi("df_", $class) == true)
    {
        include("classes/".$class.".php");
    }
}


[top]

Step 2. Creating main instance of DataForm.



// Create Main instance of DataForm

$DataForm = new df_main();


// Output your desired preset design this will automaticly add the responding
// classes to your bounded elements in addition to your eventually preset ones

$DataForm->setDesign("beach");


// Create our first Form add self as action if you want the target to be
// the page itself

$mainform = new df_form("mainform", "output2.php", false, NULL, "POST", "myform", "Registration Form");


// Binding the Form to the main DataForm instance 

$DataForm->bindForm($mainform);


[top]

Step 3. Adding elements to the form.



// Creating textbox

$elem = new df_textbox("first_name", NULL, "", "First Name:", "my_special_textbox");
$elem->setHTMLAfter('<br /><br />');
$mainform->bindElement($elem);


// Creating dropdown list

$dpvalue = array(
    array("", "-- select --"),
    array("US", "United States"),
    array("GB", "United Kingdom (Great Britain)"),
    array("OM", "Oman"),
    array("NO", "Norway"),
    array("MP", "Northern Mariana Islands"),
    array("NF", "Norfolk Island"),
    array("NU", "Niue")
);

$mydp = new df_dropdown("country", "Country", $dpvalue, "Country:");
$mydp->setHTMLAfter("<br /><br />");
$mainform->bindElement($mydp);


// Creating radio buttons

$radio1 = new df_radio("male", "male", "m", "Male:", true, "gender");
$radio2 = new df_radio("female", "female", "f", "Female:", false, "gender");
$radio2->setHTMLAfter("<br />");
$mainform->bindElement($radio1);
$mainform->bindElement($radio2);


// Creating password fields

$elem = new df_password("password", "secret", NULL, "Password:"); $elem->setHTMLAfter('<br /><br />');
$mainform->bindElement($elem);
$elem = new df_password("confirm_password", "secret", NULL, "Confirm Password:"); $elem->setHTMLAfter('<br /><br />');
$mainform->bindElement($elem);


// Creating form buttons

$mainform->bindElement(new df_submit("Submit", NULL, "Submit"));
$mainform->bindElement(new df_reset("btn_reset", NULL, "Reset"));


[top]

Step 4. Drawing output.



// Output the set Designset

echo $DataForm->includeMoo();
echo $DataForm->getDesign();


// Output the whole creation

echo $DataForm->output();