コード例 #1
0
ファイル: testcheckData.php プロジェクト: julesbl/ssp
$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();
}
コード例 #2
0
ファイル: example1.php プロジェクト: julesbl/ssp
// 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();
}
コード例 #3
0
ファイル: UserAdminBase.php プロジェクト: julesbl/ssp
 /**
  * Check email form
  * @param sfc\Form $form - form object
  * @return bool - true on success
  */
 private function changeEmailCheck(&$form)
 {
     $error = false;
     if (isset($form->elements["password"])) {
         $fields = array("UserPassword");
         $result = $this->getUser($fields, "SSP Admin: Get user password failed", $form->userId);
         if (!$this->session->checkPassword($form->getField("password"), $result->UserPassword)) {
             // no result returned for the password entered
             $form->setError("password", "Invalid password");
             $error = true;
         }
     }
     // check for duplicate emails
     if (!$this->cfg->allowDuplicateEmails) {
         $values = array("UserEmail" => SSP_Encrypt($form->getField("email")));
         $this->db->get($this->cfg->userTable, $values, "SSP Admin, change email: checking for duplicate email");
         if ($this->db->numRows()) {
             $form->setError("email", "Email is already in use.");
             $error = true;
         }
     }
     return $error;
 }