#$staff->setDateField('account_expiry_date');
$staff->setPasswordField('password');
//set up fields for validation using regexs above
$staff->validateField("firstname", "required");
$staff->validateField("lastname", "required");
$staff->validateField("username", "required");
$staff->validateField("password", "required");
#set default values
$staff->setDefaultValue('reg_date', date("Y-m-d H:i:s"));
$staff->setDefaultValue('change_password', 'Yes');
$staff->setDefaultValue('account_status', 'Active');
//set all output to be returned instead of printed
$staff->returnOutput = true;
//test for last page and no errors to submit form, otherwise start form
if (@$_POST['formitable_multipage'] != "end" || isset($staff->errMsg)) {
    $staffOpen = $staff->openForm();
    $smarty->assign('staffOpen', $staffOpen);
} else {
    $staff->submitForm(false);
}
//first page - test for no submit OR errors set with a field on the first page
if (!isset($_POST['submit']) || isset($staff->errMsg) && isset($_POST['firstname'])) {
    #print first page
    $page1 = "page 1";
    $smarty->assign('page1', $page1);
    $id = $staff->printField('identifier');
    $smarty->assign('id', $id);
    $fname = $staff->printField('firstname');
    $smarty->assign('fname', $fname);
    $lname = $staff->printField('lastname');
    $smarty->assign('lname', $lname);
#$fields = $newForm->fields();
#$newForm->printField('f_name');
#echo $newForm->fields();
#print_r($fields);
#$i = 0;
#foreach ($fields as $field){
#	echo $newForm->getFieldType($i);
#	echo $newForm->getFieldLength($i).'<br>';
#	$i++;
#}
if (isset($_GET['ID'])) {
    $newForm->getRecord($_GET['ID']);
}
//call submit method if form has been submitted
if (!isset($_POST['submit']) || isset($_POST['submit']) && $newForm->submitForm() == -1) {
    $newForm->openForm();
}
if (!isset($_POST['submit'])) {
    $newForm->openForm();
}
//hide primary key field, force a few field types
$newForm->hideField("ID");
$newForm->forceTypes(array("foods", "day_of_week"), array("checkbox", "radio"));
//get data pairs from another table
$newForm->normalizedField("toon", "formitable_toons", "ID", "name", "pkey ASC");
#print_r($newForm->_getFieldData('toon')
//set custom field labels
$newForm->labelFields(array("f_name", "l_name", "description", "pets", "foods", "color", "day_of_week", "b_day", "toon"), array("First Name", "Last Name", "About Yourself", "Your Pets", "Favorite Foods", "Favorite Color", "Favorite Day", "Your Birthday", "Favorite Cartoon"));
$newForm->registerValidation("required", ".+", "Input is required.");
$newForm->validateField("f_name", "required");
$newForm->uniqueField("f_name", "fname is already registered.");
$profile->hideFields(array('account_status'));
#custom labels
$profile->labelFields(array('firstname', 'lastname'), array('First Name *', 'Last Name *'));
//set up regular expressions for field validation
$profile->registerValidation("required", ".+", "Input is required.");
//set up fields for validation using regexs above
$profile->validateField("firstname", "required");
$profile->validateField("lastname", "required");
#set default values
#submit msg
$profile->msg_updateSuccess = "Your Profile was updated successfully.";
//set all output to be returned instead of printed
$profile->returnOutput = true;
//test for last page and no errors to submit form, otherwise start form
if (@$_POST['formitable_multipage'] != "end" || isset($profile->errMsg)) {
    $profileOpen = $profile->openForm();
    $smarty->assign('profileOpen', $profileOpen);
} else {
    $profile->submitForm(false);
}
//first page - test for no submit OR errors set with a field on the first page
if (!isset($_POST['submit']) || isset($profile->errMsg) && isset($_POST['firstname'])) {
    #print first page
    $page1 = "page 1";
    $smarty->assign('page1', $page1);
    $fname = $profile->printField('firstname');
    $smarty->assign('fname', $fname);
    $lname = $profile->printField('lastname');
    $smarty->assign('lname', $lname);
    $end = $profile->multiPage("end");
    $smarty->assign('end', $end);
$sec->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$sec->validateField("profile_id", "required");
#set default values
$sec->setDefaultValue('object', $objectpath);
$nmSQL = "SELECT profile FROM sionapros_profiles WHERE profile_id = {$_POST['profile_id']}";
$nm = $db->execute($nmSQL);
$sec->msg_insertSuccess = "The object {$objectpath} is now only accessible to users under the {$nm[0]['profile']} profile.";
//set all output to be returned instead of printed
$sec->returnOutput = true;
$smarty->assign('msg', $msg);
$smarty->assign('assignedTo', $assignedTo);
$smarty->assign('result', $result);
$smarty->assign('objectpath', $objectpath);
if (!isset($_POST['submit']) || isset($_POST['submit']) && $sec->submitForm(false) == -1) {
    $secOpen = $sec->openForm();
    $smarty->assign('secOpen', $secOpen);
    $objectId = $sec->printField('object');
    $smarty->assign('objectId', $objectId);
    $profile = $sec->printField('profile_id');
    $smarty->assign('profile', $profile);
    $secClose = $sec->closeForm();
    $smarty->assign('secClose', $secClose);
    //        $secForm = $sec->printForm();
    //        $smarty->assign('sec', $secForm);
} else {
    #submit msg
    $smarty->assign('updateMsg', $sec->submitMsg);
    #unset prevPath
    unset($_SESSION['prevPath']);
}