Changeset 526
- Timestamp:
- 08/08/07 15:52:45 (1 year ago)
- Files:
-
- trunk/build/manifests/testapp.mn (modified) (2 diffs)
- trunk/build/manifests/testapp.mn (modified) (2 diffs)
- trunk/lib/jelix-www/design/jform.css (modified) (1 diff)
- trunk/lib/jelix-www/design/jform.css (modified) (1 diff)
- trunk/lib/jelix-www/js/jforms.js (modified) (2 diffs)
- trunk/lib/jelix-www/js/jforms.js (modified) (2 diffs)
- trunk/lib/jelix/docs/ns/jforms-controls.rng (modified) (2 diffs)
- trunk/lib/jelix/docs/ns/jforms-controls.rng (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsBase.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsBase.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (13 diffs)
- trunk/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (13 diffs)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (2 diffs)
- trunk/lib/jelix/plugins/tpl/html/block.form.php (modified) (2 diffs)
- trunk/lib/jelix/plugins/tpl/html/block.form.php (modified) (2 diffs)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php (modified) (1 diff)
- trunk/lib/jelix/utils/jDatatype.class.php (modified) (5 diffs)
- trunk/lib/jelix/utils/jDatatype.class.php (modified) (5 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html.php (added)
- trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html.php (added)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html.php (modified) (9 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html.php (modified) (9 diffs)
- trunk/testapp/modules/jelix_tests/tests/utils.jdatatype.html_cli.php (added)
- trunk/testapp/modules/jelix_tests/tests/utils.jdatatype.html_cli.php (added)
- trunk/testapp/modules/testapp/controllers/sampleform.classic.php (modified) (1 diff)
- trunk/testapp/modules/testapp/controllers/sampleform.classic.php (modified) (1 diff)
- trunk/testapp/modules/testapp/forms/sample.form.xml (modified) (3 diffs)
- trunk/testapp/modules/testapp/forms/sample.form.xml (modified) (3 diffs)
- trunk/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
- trunk/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/manifests/testapp.mn
r512 r526 114 114 jdb.2_queries_with_pdo.html.php 115 115 jforms.html.php 116 jforms.check_datas.html.php 116 117 jforms.compiler.html.php 117 118 jforms.htmlbuilder.html.php … … 119 120 jtpl.compiler.html_cli.php 120 121 jtpl.expressions_parsing.html_cli.php 122 utils.jdatatype.html_cli.php 121 123 utils.jfilter.html_cli.php 122 124 trunk/build/manifests/testapp.mn
r512 r526 114 114 jdb.2_queries_with_pdo.html.php 115 115 jforms.html.php 116 jforms.check_datas.html.php 116 117 jforms.compiler.html.php 117 118 jforms.htmlbuilder.html.php … … 119 120 jtpl.compiler.html_cli.php 120 121 jtpl.expressions_parsing.html_cli.php 122 utils.jdatatype.html_cli.php 121 123 utils.jfilter.html_cli.php 122 124 trunk/lib/jelix-www/design/jform.css
r525 r526 9 9 10 10 .jforms-required { font-weight:bold; } 11 .jforms-required:after { content:"*"; font-weight:bold; } 12 .jforms-required-star {font-weight:bold; } 11 .jforms-required:after { content:"*"; font-weight:bold; color:red; } 13 12 13 .jforms-error-list { color:red; border:1px solid red;} 14 15 input.jforms-error, textarea.jforms-error, select.jforms-error {background-color: #ffd6d7;} 16 17 label.jforms-error, span.jforms-error {font-style:italic; color:red;} trunk/lib/jelix-www/design/jform.css
r525 r526 9 9 10 10 .jforms-required { font-weight:bold; } 11 .jforms-required:after { content:"*"; font-weight:bold; } 12 .jforms-required-star {font-weight:bold; } 11 .jforms-required:after { content:"*"; font-weight:bold; color:red; } 13 12 13 .jforms-error-list { color:red; border:1px solid red;} 14 15 input.jforms-error, textarea.jforms-error, select.jforms-error {background-color: #ffd6d7;} 16 17 label.jforms-error, span.jforms-error {font-style:italic; color:red;} trunk/lib/jelix-www/js/jforms.js
r522 r526 166 166 _getValue : function (elt){ 167 167 var value=''; 168 switch (elt.localName.toLowerCase()) { 169 case "input": 170 switch (elt.getAttribute("type")) { 171 case "checkbox": 172 case "radio": 173 if (elt.checked) 174 value = 'true'; 175 else 176 value = 'false'; 168 if(elt.nodeType) { // this is a node 169 switch (elt.localName.toLowerCase()) { 170 case "input": 171 switch (elt.getAttribute("type")) { 172 case "checkbox": 173 case "radio": 174 if (elt.checked) 175 value = 'true'; 176 else 177 value = 'false'; 178 break; 179 default: 180 value = elt.value; 181 break; 182 } 177 183 break; 178 default:179 value = elt.value;184 case "textarea": 185 value= elt.value; 180 186 break; 187 case "select": 188 if (!elt.multiple) { 189 value = elt.value; 190 break; 191 } 192 var options = elt.getElementsByTagName("option"); 193 value = []; 194 for (var i = 0; i < options.length; i++) { 195 if (options[i].selected) { 196 value.push(options[i].value); 197 } 198 } 199 break; 200 } 201 } else if(elt.item){ 202 // this is a NodeList of radio buttons 203 value = [] 204 for (var i = 0; i < elt.length; i++) { 205 var radio = elt.item(i); 206 if (radio.checked) { 207 value.push(radio.value); 181 208 } 182 break; 183 case "textarea": 184 value= elt.value; 185 break; 186 case "select": 187 if (!elt.multiple) { 188 value = elt.value; 189 break; 190 } 191 var options = elt.getElementsByTagName("option"); 192 value = []; 193 for (i = 0; i < options.length; i++) { 194 if (options[i].selected) { 195 value.push(options[i].value); 196 } 197 } 198 break; 209 } 199 210 } 200 211 return value; 201 212 }, 202 213 203 showHelp : function(aForm , aControl){204 var frm = this._forms[aForm .name];214 showHelp : function(aFormName, aControlName){ 215 var frm = this._forms[aFormName]; 205 216 var ctrls = frm.controls; 206 217 var ctrl = null; 207 218 for(var i=0; i < ctrls.length; i++){ 208 if (ctrls[i].name == aControl ) {219 if (ctrls[i].name == aControlName) { 209 220 ctrl = ctrls[i]; 210 221 break; … … 272 283 addError : function(control, messageType){ 273 284 if(messageType == 1){ 274 this.message += control.errRequired + "\n";285 this.message +="* "+control.errRequired + "\n"; 275 286 }else if(messageType == 2){ 276 this.message += control.errInvalid + "\n";287 this.message +="* "+control.errInvalid + "\n"; 277 288 }else{ 278 this.message += " Error on '"+control.label+"' field\n";289 this.message += "* Error on '"+control.label+"' field\n"; 279 290 } 280 291 }, trunk/lib/jelix-www/js/jforms.js
r522 r526 166 166 _getValue : function (elt){ 167 167 var value=''; 168 switch (elt.localName.toLowerCase()) { 169 case "input": 170 switch (elt.getAttribute("type")) { 171 case "checkbox": 172 case "radio": 173 if (elt.checked) 174 value = 'true'; 175 else 176 value = 'false'; 168 if(elt.nodeType) { // this is a node 169 switch (elt.localName.toLowerCase()) { 170 case "input": 171 switch (elt.getAttribute("type")) { 172 case "checkbox": 173 case "radio": 174 if (elt.checked) 175 value = 'true'; 176 else 177 value = 'false'; 178 break; 179 default: 180 value = elt.value; 181 break; 182 } 177 183 break; 178 default:179 value = elt.value;184 case "textarea": 185 value= elt.value; 180 186 break; 187 case "select": 188 if (!elt.multiple) { 189 value = elt.value; 190 break; 191 } 192 var options = elt.getElementsByTagName("option"); 193 value = []; 194 for (var i = 0; i < options.length; i++) { 195 if (options[i].selected) { 196 value.push(options[i].value); 197 } 198 } 199 break; 200 } 201 } else if(elt.item){ 202 // this is a NodeList of radio buttons 203 value = [] 204 for (var i = 0; i < elt.length; i++) { 205 var radio = elt.item(i); 206 if (radio.checked) { 207 value.push(radio.value); 181 208 } 182 break; 183 case "textarea": 184 value= elt.value; 185 break; 186 case "select": 187 if (!elt.multiple) { 188 value = elt.value; 189 break; 190 } 191 var options = elt.getElementsByTagName("option"); 192 value = []; 193 for (i = 0; i < options.length; i++) { 194 if (options[i].selected) { 195 value.push(options[i].value); 196 } 197 } 198 break; 209 } 199 210 } 200 211 return value; 201 212 }, 202 213 203 showHelp : function(aForm , aControl){204 var frm = this._forms[aForm .name];214 showHelp : function(aFormName, aControlName){ 215 var frm = this._forms[aFormName]; 205 216 var ctrls = frm.controls; 206 217 var ctrl = null; 207 218 for(var i=0; i < ctrls.length; i++){ 208 if (ctrls[i].name == aControl ) {219 if (ctrls[i].name == aControlName) { 209 220 ctrl = ctrls[i]; 210 221 break; … … 272 283 addError : function(control, messageType){ 273 284 if(messageType == 1){ 274 this.message += control.errRequired + "\n";285 this.message +="* "+control.errRequired + "\n"; 275 286 }else if(messageType == 2){ 276 this.message += control.errInvalid + "\n";287 this.message +="* "+control.errInvalid + "\n"; 277 288 }else{ 278 this.message += " Error on '"+control.label+"' field\n";289 this.message += "* Error on '"+control.label+"' field\n"; 279 290 } 280 291 }, trunk/lib/jelix/docs/ns/jforms-controls.rng
r523 r526 12 12 <ref name="hint" /> 13 13 </optional> 14 <!--15 14 <optional> 16 15 <ref name="alert" /> 17 16 </optional> 18 <optional>19 <ref name="help" />20 </optional>-->21 17 </define> 22 18 <!-- … … 324 320 </define> 325 321 326 <!--327 322 <define name="alert"> 328 323 <element name="alert"> 324 <optional> 325 <attribute name="type"> 326 <choice> 327 <value>required</value> 328 <value>invalid</value> 329 </choice> 330 </attribute> 331 </optional> 329 332 <ref name="message.content" /> 330 333 </element> 331 334 </define> 332 -->333 335 </grammar> trunk/lib/jelix/docs/ns/jforms-controls.rng
r523 r526 12 12 <ref name="hint" /> 13 13 </optional> 14 <!--15 14 <optional> 16 15 <ref name="alert" /> 17 16 </optional> 18 <optional>19 <ref name="help" />20 </optional>-->21 17 </define> 22 18 <!-- … … 324 320 </define> 325 321 326 <!--327 322 <define name="alert"> 328 323 <element name="alert"> 324 <optional> 325 <attribute name="type"> 326 <choice> 327 <value>required</value> 328 <value>invalid</value> 329 </choice> 330 </attribute> 331 </optional> 329 332 <ref name="message.content" /> 330 333 </element> 331 334 </define> 332 -->333 335 </grammar> trunk/lib/jelix/forms/jFormsBase.class.php
r504 r526 94 94 foreach($this->_controls as $name=>$ctrl){ 95 95 $value=$this->_container->datas[$name]; 96 if( $value === null && $ctrl->required){97 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED;98 }else{99 if(is_array($value)){96 if(is_array($value)){ 97 if(count($value) == 0 && $ctrl->required){ 98 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 99 }else{ 100 100 foreach($value as $v){ 101 101 if(!$ctrl->datatype->check($v)){ … … 104 104 } 105 105 } 106 }elseif(!$ctrl->datatype->check($value)){ 107 $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 106 } 107 }else{ 108 if($value == '' && $ctrl->required){ 109 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 110 }else{ 111 if($ctrl->type == 'checkbox' && $value ==''){ 112 $value='false'; 113 } 114 if(!$ctrl->datatype->check($value)){ 115 $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 116 } 108 117 } 109 118 } trunk/lib/jelix/forms/jFormsBase.class.php
r504 r526 94 94 foreach($this->_controls as $name=>$ctrl){ 95 95 $value=$this->_container->datas[$name]; 96 if( $value === null && $ctrl->required){97 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED;98 }else{99 if(is_array($value)){96 if(is_array($value)){ 97 if(count($value) == 0 && $ctrl->required){ 98 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 99 }else{ 100 100 foreach($value as $v){ 101 101 if(!$ctrl->datatype->check($v)){ … … 104 104 } 105 105 } 106 }elseif(!$ctrl->datatype->check($value)){ 107 $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 106 } 107 }else{ 108 if($value == '' && $ctrl->required){ 109 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 110 }else{ 111 if($ctrl->type == 'checkbox' && $value ==''){ 112 $value='false'; 113 } 114 if(!$ctrl->datatype->check($value)){ 115 $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 116 } 108 117 } 109 118 } trunk/lib/jelix/forms/jFormsBuilderBase.class.php
r525 r526 95 95 //]]> 96 96 </script>'; 97 $errors = $this->_form->getContainer()->errors; 98 if(count($errors)){ 99 $ctrls = $this->_form->getControls(); 100 echo '<ul class="jforms-error-list">'; 101 $errRequired=''; 102 foreach($errors as $cname => $err){ 103 if($err == JFORM_ERRDATA_REQUIRED) { 104 if($ctrls[$cname]->alertRequired){ 105 echo '<li>', $ctrls[$cname]->alertRequired,'</li>'; 106 }else{ 107 echo '<li>', jLocale::get('jelix~formserr.js.err.required', $ctrls[$cname]->label),'</li>'; 108 } 109 }else{ 110 if($ctrls[$cname]->alertRequired){ 111 echo '<li>', $ctrls[$cname]->alertInvalid,'</li>'; 112 }else{ 113 echo '<li>', jLocale::get('jelix~formserr.js.err.invalid', $ctrls[$cname]->label),'</li>'; 114 } 115 } 116 117 } 118 echo '</ul>'; 119 } 97 120 } 98 121 … … 103 126 public function outputControlLabel($ctrl){ 104 127 $required = ($ctrl->required == ''?'':' jforms-required'); 128 $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 129 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 105 130 if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons'){ 106 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 107 echo '<span class="jforms-label',$required,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 131 echo '<span class="jforms-label',$required,$inError,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 108 132 }else if($ctrl->type != 'submit'){ 109 133 $id = $this->_name.'_'.$ctrl->ref; 110 echo '<label class="jforms-label',$required, '" for="'.$id.'">'.htmlspecialchars($ctrl->label).'</label>';134 echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 111 135 } 112 136 } … … 116 140 $readonly = ($ctrl->readonly?' readonly="readonly"':''); 117 141 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 118 142 $class = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' class="jforms-error"':''); 119 143 switch($ctrl->type){ 120 144 case 'input': … … 122 146 if($value === null) 123 147 $value = $ctrl->defaultValue; 124 echo '<input type="text"',$id,$readonly,$hint, ' value="',htmlspecialchars($value),'"/>';148 echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"/>'; 125 149 break; 126 150 case 'checkbox': … … 133 157 $v=""; 134 158 } 135 echo '<input type="checkbox"',$id,$readonly,$hint,$ v,' value="true"/>';159 echo '<input type="checkbox"',$id,$readonly,$hint,$class,$v,' value="true"/>'; 136 160 break; 137 161 case 'checkboxes': … … 152 176 if(in_array($v,$value)) 153 177 echo ' checked="checked"'; 154 echo $readonly, '/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>';178 echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 155 179 $i++; 156 180 } … … 160 184 if($v == $value) 161 185 echo ' checked="checked"'; 162 echo $readonly, '/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>';186 echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 163 187 $i++; 164 188 } … … 174 198 } 175 199 foreach($ctrl->datasource->getDatas() as $v=>$label){ 176 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly, '/>';200 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,$class,'/>'; 177 201 echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label>'; 178 202 $i++; … … 180 204 break; 181 205 case 'menulist': 182 echo '<select',$id,$readonly,$hint, ' size="1">';206 echo '<select',$id,$readonly,$hint,$class,' size="1">'; 183 207 $value = $this->_form->getData($ctrl->ref); 184 208 if($value === null){ … … 193 217 case 'listbox': 194 218 if($ctrl->multiple){ 195 echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint, ' size="',$ctrl->size,'" multiple="multiple">';219 echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,$class,' size="',$ctrl->size,'" multiple="multiple">'; 196 220 $value = $this->_form->getData($ctrl->ref); 197 221 if($value == null){ … … 225 249 } 226 250 227 echo '<select',$id,$readonly,$hint, ' size="',$ctrl->size,'">';251 echo '<select',$id,$readonly,$hint,$class,' size="',$ctrl->size,'">'; 228 252 foreach($ctrl->datasource->getDatas() as $v=>$label){ 229 253 echo '<option value="',htmlspecialchars($v),'"',($v==$value?' selected="selected"':''),'>',htmlspecialchars($label),'</option>'; … … 236 260 if($value === null) 237 261 $value = $ctrl->defaultValue; 238 echo '<textarea',$id,$readonly,$hint, '>',htmlspecialchars($value),'</textarea>';262 echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>'; 239 263 break; 240 264 case 'secret': 241 echo '<input type="password"',$id,$readonly,$hint, ' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>';265 echo '<input type="password"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 242 266 break; 243 267 case 'output': … … 249 273 break; 250 274 case 'upload': 251 echo '<input type="file"',$id,$readonly,$hint, ' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),'275 echo '<input type="file"',$id,$readonly,$hint,$class,' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 252 276 break; 253 277 case 'submit': trunk/lib/jelix/forms/jFormsBuilderBase.class.php
r525 r526 95 95 //]]> 96 96 </script>'; 97 $errors = $this->_form->getContainer()->errors; 98 if(count($errors)){ 99 $ctrls = $this->_form->getControls(); 100 echo '<ul class="jforms-error-list">'; 101 $errRequired=''; 102 foreach($errors as $cname => $err){ 103 if($err == JFORM_ERRDATA_REQUIRED) { 104 if($ctrls[$cname]->alertRequired){ 105 echo '<li>', $ctrls[$cname]->alertRequired,'</li>'; 106 }else{ 107 echo '<li>', jLocale::get('jelix~formserr.js.err.required', $ctrls[$cname]->label),'</li>'; 108 } 109 }else{ 110 if($ctrls[$cname]->alertRequired){ 111 echo '<li>', $ctrls[$cname]->alertInvalid,'</li>'; 112 }else{ 113 echo '<li>', jLocale::get('jelix~formserr.js.err.invalid', $ctrls[$cname]->label),'</li>'; 114 } 115 } 116 117 } 118 echo '</ul>'; 119 } 97 120 } 98 121 … … 103 126 public function outputControlLabel($ctrl){ 104 127 $required = ($ctrl->required == ''?'':' jforms-required'); 128 $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 129 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 105 130 if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons'){ 106 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 107 echo '<span class="jforms-label',$required,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 131 echo '<span class="jforms-label',$required,$inError,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 108 132 }else if($ctrl->type != 'submit'){ 109 133 $id = $this->_name.'_'.$ctrl->ref; 110 echo '<label class="jforms-label',$required, '" for="'.$id.'">'.htmlspecialchars($ctrl->label).'</label>';134 echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 111 135 } 112 136 } … … 116 140 $readonly = ($ctrl->readonly?' readonly="readonly"':''); 117 141 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 118 142 $class = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' class="jforms-error"':''); 119 143 switch($ctrl->type){ 120 144 case 'input': … … 122 146 if($value === null) 123 147 $value = $ctrl->defaultValue; 124 echo '<input type="text"',$id,$readonly,$hint, ' value="',htmlspecialchars($value),'"/>';148 echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"/>'; 125 149 break; 126 150 case 'checkbox': … … 133 157 $v=""; 134 158 } 135 echo '<input type="checkbox"',$id,$readonly,$hint,$ v,' value="true"/>';159 echo '<input type="checkbox"',$id,$readonly,$hint,$class,$v,' value="true"/>'; 136 160 break; 137 161 case 'checkboxes': … … 152 176 if(in_array($v,$value)) 153 177 echo ' checked="checked"'; 154 echo $readonly, '/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>';178 echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 155 179 $i++; 156 180 } … … 160 184 if($v == $value) 161 185 echo ' checked="checked"'; 162 echo $readonly, '/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>';186 echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 163 187 $i++; 164 188 } … … 174 198 } 175 199 foreach($ctrl->datasource->getDatas() as $v=>$label){ 176 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly, '/>';200 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,$class,'/>'; 177 201 echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label>'; 178 202 $i++; … … 180 204 break; 181 205 case 'menulist': 182 echo '<select',$id,$readonly,$hint, ' size="1">';206 echo '<select',$id,$readonly,$hint,$class,' size="1">'; 183 207 $value = $this->_form->getData($ctrl->ref); 184 208 if($value === null){ … … 193 217 case 'listbox': 194 218 if($ctrl->multiple){ 195 echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint, ' size="',$ctrl->size,'" multiple="multiple">';219 echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,$class,' size="',$ctrl->size,'" multiple="multiple">'; 196 220 $value = $this->_form->getData($ctrl->ref); 197 221 if($value == null){ … … 225 249 } 226 250 227 echo '<select',$id,$readonly,$hint, ' size="',$ctrl->size,'">';251 echo '<select',$id,$readonly,$hint,$class,' size="',$ctrl->size,'">'; 228 252 foreach($ctrl->datasource->getDatas() as $v=>$label){ 229 253 echo '<option value="',htmlspecialchars($v),'"',($v==$value?' selected="selected"':''),'>',htmlspecialchars($label),'</option>'; … … 236 260 if($value === null) 237 261 $value = $ctrl->defaultValue; 238 echo '<textarea',$id,$readonly,$hint, '>',htmlspecialchars($value),'</textarea>';262 echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>'; 239 263 break; 240 264 case 'secret': 241 echo '<input type="password"',$id,$readonly,$hint, ' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>';265 echo '<input type="password"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 242 266 break; 243 267 case 'output': … … 249 273 break; 250 274 case 'upload': 251 echo '<input type="file"',$id,$readonly,$hint, ' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),'275 echo '<input type="file"',$id,$readonly,$hint,$class,' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 252 276 break; 253 277 case 'submit': trunk/lib/jelix/forms/jFormsControl.class.php
r523 r526 19 19 public $type = null; 20 20 public $ref=''; 21 public $datatype ='string';21 public $datatype; 22 22 public $required = false; 23 23 public $readonly = false; … … 31 31 function __construct($ref){ 32 32 $this->ref = $ref; 33 $this->datatype = new jDatatypeString(); 33 34 } 34 35 trunk/lib/jelix/forms/jFormsControl.class.php
r523 r526 19 19 public $type = null; 20 20 public $ref=''; 21 public $datatype ='string';21 public $datatype; 22 22 public $required = false; 23 23 public $readonly = false; … … 31 31 function __construct($ref){ 32 32 $this->ref = $ref; 33 $this->datatype = new jDatatypeString(); 33 34 } 34 35 trunk/lib/jelix/plugins/tpl/html/block.form.php
r525 r526 41 41 } 42 42 43 if(isset($param[3]) && $param[3] ! '')43 if(isset($param[3]) && $param[3] != '') 44 44 $errdecorator = $param[3]; 45 45 else 46 46 $errdecorator = "'jFormsErrorDecoratorAlert'"; 47 47 48 if(isset($param[4]) && $param[4] ! '')48 if(isset($param[4]) && $param[4] != '') 49 49 $helpdecorator = $param[4]; 50 50 else … … 55 55 $t->_privateVars[\'__builder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.')); 56 56 if($GLOBALS[\'gJCoord\']->response!= null){ 57 $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\' basePath\'].\'jelix/js/jforms.js\');58 $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\' basePath\'].\'jelix/design/jforms.css\');57 $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'js/jforms.js\'); 58 $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'design/jform.css\'); 59 59 } 60 60 '; trunk/lib/jelix/plugins/tpl/html/block.form.php
r525 r526 41 41 } 42 42 43 if(isset($param[3]) && $param[3] ! '')43 if(isset($param[3]) && $param[3] != '') 44 44 $errdecorator = $param[3]; 45 45 else 46 46 $errdecorator = "'jFormsErrorDecoratorAlert'"; 47 47 48 if(isset($param[4]) && $param[4] ! '')48 if(isset($param[4]) && $param[4] != '') 49 49 $helpdecorator = $param[4]; 50 50 else
