/**
  * Generate HTML output - build form
  *
  * @param string $blnClientSide Render javascript code or not, defaults to true
  * @param string $blnForceSubmitted This forces the form rendering as if the fields are submitted
  * @param string $strCustomJs Inject custom javascript to be executed while
  * initializing ValidForm Builder client-side.
  *
  * @return string Generated HTML output
  */
 public function toHtml($blnClientSide = true, $blnForceSubmitted = null, $strCustomJs = "")
 {
     $strOutput = "";
     if ($blnClientSide) {
         $strOutput .= $this->__toJS($strCustomJs);
     }
     $strClass = "validform vf__cf";
     if (is_array($this->__meta)) {
         if (isset($this->__meta["class"])) {
             $strClass .= " " . $this->__meta["class"];
         }
     }
     $blnForceSubmitted = is_null($blnForceSubmitted) ? $this->isSubmitted() : $blnForceSubmitted;
     $strOutput .= "<form " . "id=\"{$this->__name}\" " . "method=\"post\" " . "enctype=\"multipart/form-data\" " . "action=\"{$this->__action}\" " . "class=\"{$strClass}\"{$this->__metaToData()}>\n";
     // *** Main error.
     if ($blnForceSubmitted && !empty($this->__mainalert)) {
         $strOutput .= "<div class=\"vf__main_error\"><p>{$this->__mainalert}</p></div>\n";
     }
     if (!empty($this->__description)) {
         $strOutput .= "<div class=\"vf__description\"><p>{$this->__description}</p></div>\n";
     }
     $blnNavigation = false;
     $strOutput .= $this->fieldsToHtml($blnForceSubmitted, $blnNavigation);
     if (!$blnNavigation) {
         $strOutput .= "<div class=\"vf__navigation vf__cf\">\n";
         $strOutput .= "<input type=\"submit\" value=\"{$this->__submitlabel}\" class=\"vf__button\" />\n";
         $strOutput .= "</div>\n";
     }
     $strOutput .= "<input type=\"hidden\" name=\"vf__dispatch\" value=\"{$this->__name}\" />\n";
     if ($this->__usecsrfprotection) {
         $strOutput .= "<input type=\"hidden\" name=\"" . CSRF::TOKEN_NAME . "\" value=\"" . CSRF::getToken() . "\" />\n";
     }
     $strOutput .= "</form>";
     return $strOutput;
 }
示例#2
0
文件: CSRF.php 项目: joshmoody/csrf
 public function testGetAsArray()
 {
     $token = CSRFTokenGenerator::getToken();
 }