// form definition // id name for the table is used for detection of submission and error messages $form = new sfc\Form(SSP_Path(true), "tableNameForSql", "idNameforTable"); $form->tpl = $mainTemplate; // main template to enclose the form, not required, form inserted into {content} $form->tplf = "example1.tpl"; // display template for the form $form->tda("miscTplData", "Some data for display on the form template, password is 'thingy'"); $form->fe("text", "firstElement", "First element, a text box"); $form->fep("required=true, dataType=text"); // element is required and is of data type text $form->fe("password", "pasword", "enter a password"); $form->fep("required=true, dataType=password, load=false"); $form->addHidden("hiddenStuff", "Some hidden stuff", "text"); // hidden field // check for submission if ($form->processForm($_POST)) { // check for error if (!$form->error) { // check password if ($form->getField("pasword") != "thingy") { $form->addError("Error in the form"); $form->setError("pasword", "Error in password"); echo $form->create(true); } else { echo "Submission succesful"; } } } else { echo $form->create(); }
$form->fe("text", "timeType", "Time input", ">"); $form->fep("dataType=time"); $form->fe("text", "phoneType", "Phone input", ">"); $form->fep("dataType=phone"); $form->fe("text", "intType", "Integer input", ">"); $form->fep("dataType=int"); $form->fe("text", "realType", "Real input", ">"); $form->fep("dataType=real"); $form->fe("text", "hexType", "Hexadecimal input", ">"); $form->fep("dataType=hex"); $form->fe("text", "octType", "Octal input", ">"); $form->fep("dataType=oct"); $form->fe("text", "binType", "Binary input", ">"); $form->fep("dataType=bin"); $form->fe("text", "textRequired", "Text input required"); $form->fep('required = true'); $form->fe("text", "textMinChars", "Text minimum number of characters required", '12'); $form->fep('minChar = 3'); $form->fe("text", "textMaxChars", "Text maximum number of characters required", '123456'); $form->fep('maxChar = 5'); if ($form->processForm($_POST)) { if (!$form->error) { echo $form->create(true); } else { $form->addError('A global error'); $form->setError('passwordType', 'A local error added to the password field'); echo $form->create(true); } } else { echo $form->create(); }