1313use Ajax \semantic \components \Form ;
1414use Ajax \common \html \BaseHtml ;
1515use Ajax \common \html \HtmlDoubleElement ;
16+ use Ajax \semantic \components \validation \FieldValidation ;
1617
1718/**
1819 * Semantic Form component
@@ -32,6 +33,8 @@ class HtmlForm extends HtmlSemCollection {
3233 * @var array
3334 */
3435 protected $ _validationParams ;
36+
37+ protected $ _extraFieldRules ;
3538
3639 public function __construct ($ identifier , $ elements =array ()) {
3740 parent ::__construct ($ identifier , "form " , "ui form " );
@@ -40,6 +43,7 @@ public function __construct($identifier, $elements=array()) {
4043 $ this ->_fields =array ();
4144 $ this ->addItems ($ elements );
4245 $ this ->_validationParams =[];
46+ $ this ->_extraFieldRules =[];
4347 }
4448
4549 protected function getForm (){
@@ -186,9 +190,19 @@ public function run(JsUtils $js) {
186190 }
187191 }
188192 }
193+ foreach ($ this ->_extraFieldRules as $ field =>$ fieldValidation ){
194+ $ compo =$ this ->addExtraCompoValidation ($ compo , $ fieldValidation );
195+ }
189196 $ this ->_runValidationParams ($ compo ,$ js );
190197 return $ this ->_bsComponent ;
191198 }
199+
200+ public function getExtraFieldValidation ($ fieldname ){
201+ if (!isset ($ this ->_extraFieldRules [$ fieldname ])){
202+ $ this ->_extraFieldRules [$ fieldname ]=new FieldValidation ($ fieldname );
203+ }
204+ return $ this ->_extraFieldRules [$ fieldname ];
205+ }
192206
193207 public function addValidationParam ($ paramName ,$ paramValue ,$ before ="" ,$ after ="" ){
194208 $ this ->addBehavior ($ this ->_validationParams , $ paramName , $ paramValue ,$ before ,$ after );
0 commit comments