phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Form.php
Go to the documentation of this file.
1 <?php
3 
4 use Ajax\JsUtils;
12 class Form extends SimpleSemExtComponent {
13 
17  public function __construct(JsUtils $js=null) {
18  parent::__construct($js);
19  $this->uiName="form";
20  $this->params["fields"]=[];
21  }
22 
23  public function addField($identifier){
24  $this->params["fields"][$identifier]=new FieldValidation($identifier);
25  }
26 
27  public function setInline($value){
28  return $this->setParam("inline", true);
29  }
30 
31  public function setOn($value){
32  return $this->setParam("on", $value);
33  }
34 
35 
36 
43  public function addFieldRule($identifier,$type,$prompt=NULL,$value=NULL){
44  if(isset($this->params["fields"][$identifier])===false){
45  $this->addField($identifier);
46  }
47  $this->params["fields"][$identifier]->addRule($type,$prompt,$value);
48  }
49 
53  public function addFieldValidation($fieldValidation){
54  $this->params["fields"][$fieldValidation->getIdentifier()]=$fieldValidation;
55  }
56 
57  public function setJs(JsUtils $js){
58  $this->js=$js;
59  }
60 
61  public function getScript() {
62  $allParams=$this->params;
63  $this->jquery_code_for_compile=array ();
64  $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");";
65  $this->compileEvents();
66  return $this->compileJQueryCode();
67  }
68 
69  public function onValid($jsCode){
70  $this->addComponentEvent("onValid", $jsCode);
71  }
72 }
addFieldValidation($fieldValidation)
Definition: Form.php:53
JQuery PHP library.
Definition: JsUtils.php:23
addFieldRule($identifier, $type, $prompt=NULL, $value=NULL)
Definition: Form.php:43
__construct(JsUtils $js=null)
Definition: Form.php:17
addField($identifier)
Definition: Form.php:23