//force a few field types $newForm->forceTypes(array("UserType", "WkDays", "Occupation", "Address", "Address2", "City", "Password"), array("select", "checkbox", "text", "text", "text", "text", "password")); //retrieve normalized data from another table $newForm->normalizedField("UserType", "field_data", "ID", "name", "ID ASC", "type='user'"); $newForm->normalizedField("NewsLetter", "field_data", "ID", "name", "ID DESC", "type='yn'"); $newForm->normalizedField("Donation", "field_data", "ID", "name", "ID ASC", "type='donate'"); $newForm->normalizedField("recurring_Method", "field_data", "ID", "name", "ID ASC", "type='recurring'"); $newForm->normalizedField("Donation_Type", "field_data", "ID", "name", "ID ASC", "type='dtype'"); $newForm->normalizedField("NamePosted", "field_data", "ID", "name", "ID DESC", "type='yn'"); $newForm->normalizedField("volunteer", "field_data", "ID", "name", "ID ASC", "type='volunteer'"); $newForm->normalizedField("gender", "field_data", "ID", "name", "ID ASC", "type='gender'"); $newForm->normalizedField("WkDays", "field_data", "ID", "name", "ID ASC", "type='days'"); $newForm->normalizedField("StateCode", "states", "Code", "Name", "Name ASC"); //set custom field labels $newForm->labelFields(array("FName", "MName", "LName", "UserType", "FindUs", "NewsLetter", "volunteer", "Donation", "NamePosted", "WkDays", "PostalCode", "StateCode", "TelePhone", "Mobile", "Facsimile", "Details"), array("First Name", "Middle Name", "Last Name", "I am a", "How did you find us?", "Subscribe to our newsletter?", "I want to Volunteer", "I would like to donate", "Add name to Sponsors page?", "I can work these days", "Zip Code", "State", "Home Phone", "Cell Phone", "FAX", "Personal Message")); $newForm->labelField("Password_verify", "Verify Password"); //don't output field sets (<fieldset> tag) #$newForm->fieldSets=false; //set up regular expressions for field validation $newForm->registerValidation("required", ".+", "Input is required."); $newForm->registerValidation("valid_email", '^[a-zA-Z0-9_]{2,50}@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.?]+$', "Invalid email address."); $newForm->registerValidation("uspostal", "^[0-9]{5}(-?[0-9]{4})?\$", "Invalid US Postal Code."); $newForm->registerValidation("currency_us", "^([0-9]+(\\.[0-9]{2})?)?\$", "Use dollar amount only."); $newForm->registerValidation("six_chars", ".{6,}", "Enter at least six characters."); //set up fields for validation using regexs above $newForm->validateField("FName", "required"); $newForm->validateField("Email", "valid_email"); $newForm->validateField("Donation_Amount", "currency_us"); $newForm->validateField("Password", "six_chars"); //require the email field to be unique in the database (doesn't already exist) $newForm->uniqueField("Email", "Email is already registered.");
<?php require_once './classes/security.class.php'; $security = new Security($db); #create form object $sec = new Formitable($db, 'sionapros_profiles'); $sec->forceTypes(array('profile_id'), array('hidden')); #custom labels $sec->labelField('profile', 'Profile Name *'); $sec->labelField('remarks', 'Remarks i.e Describe the Profile'); //set up regular expressions for field validation $sec->registerValidation("required", ".+", "Field MUST be filled in please."); //set up fields for validation using regexs above $sec->validateField("profile", "required"); $sec->validateField("remarks", "required"); $sec->uniqueField("profile", "This Profile Name Already Exists"); #set default values $sec->setDefaultValue('profile_id', $security->getProfileId()); #submit msg $sec->msg_insertSuccess = "A new profile called {$_POST['profile']} was created."; //set all output to be returned instead of printed $sec->returnOutput = true; if (!isset($_POST['submit']) || isset($_POST['submit']) && $sec->submitForm(false) == -1) { $secForm = $sec->printForm(); $smarty->assign('sec', $secForm); } else { $smarty->assign('updateMsg', $sec->submitMsg); #unset prevPath unset($_SESSION['prevPath']); } $content = $smarty->fetch("./security/tm0.security.create_profile.tpl.html");
$objectpath = $_REQUEST['filename']; #$objectpath = basename($objectpath); } } $security = new Security($db); $result = $security->profileObjects($objectpath); if (count($result) == 0) { $assignedTo = 'NONE'; } #create form object $sec = new Formitable($db, 'sionapros_object_profile'); $sec->forceTypes(array('object'), array('hidden')); $sec->skipFields(array('activefolder', 'filename')); $sec->normalizedField('profile_id', 'sionapros_profiles', 'profile_id', 'profile', 'profile_id ASC'); #custom labels $sec->labelField('profile_id', 'Profile *'); //set up regular expressions for field validation $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);