@@ -6,18 +6,18 @@ discard block |
||
| 6 | 6 | use Ajax\service\AjaxCall; |
| 7 | 7 | use Ajax\JsUtils; |
| 8 | 8 | |
| 9 | -trait FormTrait{ |
|
| 9 | +trait FormTrait { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @return HtmlForm |
| 13 | 13 | */ |
| 14 | 14 | abstract protected function getForm(); |
| 15 | 15 | |
| 16 | - protected function addCompoValidation($js,$compo,$field){ |
|
| 16 | + protected function addCompoValidation($js, $compo, $field) { |
|
| 17 | 17 | $form=$this->getForm(); |
| 18 | 18 | $validation=$field->getValidation(); |
| 19 | - if(isset($validation)){ |
|
| 20 | - if(isset($compo)===false){ |
|
| 19 | + if (isset($validation)) { |
|
| 20 | + if (isset($compo)===false) { |
|
| 21 | 21 | $compo=$js->semantic()->form("#".$form->getIdentifier()); |
| 22 | 22 | } |
| 23 | 23 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | return $compo; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
| 29 | + protected function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
| 30 | 30 | $form=$this->getForm(); |
| 31 | 31 | $params=$form->getValidationParams(); |
| 32 | - if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){ |
|
| 32 | + if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) { |
|
| 33 | 33 | $compilation=$params["_ajaxSubmit"]->compile($js); |
| 34 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
| 34 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
| 35 | 35 | $this->onSuccess($compilation); |
| 36 | 36 | unset($params["_ajaxSubmit"]); |
| 37 | 37 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | return $this->getForm()->addToProperty("class", "loading"); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function addErrorMessage(){ |
|
| 47 | + public function addErrorMessage() { |
|
| 48 | 48 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -59,35 +59,35 @@ discard block |
||
| 59 | 59 | * @param string $responseElement |
| 60 | 60 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 61 | 61 | */ |
| 62 | - public function submitOn($event,$identifier,$url,$responseElement){ |
|
| 62 | + public function submitOn($event, $identifier, $url, $responseElement) { |
|
| 63 | 63 | $form=$this->getForm(); |
| 64 | 64 | $elem=$form->getElementById($identifier, $form->getContent()); |
| 65 | - if(isset($elem)){ |
|
| 66 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement); |
|
| 65 | + if (isset($elem)) { |
|
| 66 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement); |
|
| 67 | 67 | } |
| 68 | 68 | return $form; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function submitOnClick($identifier,$url,$responseElement){ |
|
| 71 | + public function submitOnClick($identifier, $url, $responseElement) { |
|
| 72 | 72 | return $this->submitOn("click", $identifier, $url, $responseElement); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
| 76 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
| 77 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement); |
|
| 75 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
| 76 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
| 77 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL){ |
|
| 80 | + protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL) { |
|
| 81 | 81 | $form=$this->getForm(); |
| 82 | - if(isset($url) && isset($responseElement)){ |
|
| 82 | + if (isset($url) && isset($responseElement)) { |
|
| 83 | 83 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');"); |
| 84 | - $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url])); |
|
| 84 | + $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", ["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url])); |
|
| 85 | 85 | } |
| 86 | 86 | return $button; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
| 90 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
| 89 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
| 90 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
| 91 | 91 | $bt->setProperty("type", "reset"); |
| 92 | 92 | return $bt; |
| 93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string $jsCode |
| 98 | 98 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 99 | 99 | */ |
| 100 | - public function onValid($jsCode){ |
|
| 100 | + public function onValid($jsCode) { |
|
| 101 | 101 | $form=$this->getForm(); |
| 102 | 102 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
| 103 | 103 | return $form; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param string $jsCode can use event and fields parameters |
| 109 | 109 | * @return HtmlForm |
| 110 | 110 | */ |
| 111 | - public function onSuccess($jsCode){ |
|
| 111 | + public function onSuccess($jsCode) { |
|
| 112 | 112 | $form=$this->getForm(); |
| 113 | 113 | $form->addValidationParam("onSuccess", "%function(evt,fields){".$jsCode."}%"); |
| 114 | 114 | return $form; |