Changeset 453
- Timestamp:
- 06/04/07 23:38:09 (1 year ago)
- Files:
-
- branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng (modified) (6 diffs)
- branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng (modified) (6 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (7 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (7 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsDatasource.class.php (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/forms/jFormsDatasource.class.php (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/unittest/classes/utjforms.class.php (modified) (12 diffs)
- branches/experimental/jforms/testapp/modules/unittest/classes/utjforms.class.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng
r442 r453 23 23 <define name="UI.Common.data"> 24 24 <optional><ref name="datatypes" /></optional> 25 <ref name="UI.attr.readonly" /> 26 <optional><attribute name="required"><choice><value>true</value><value>false</value></choice></attribute></optional> 27 </define> 28 29 <define name="UI.attr.readonly"> 25 30 <optional><attribute name="readonly"><choice><value>true</value><value>false</value></choice></attribute></optional> 26 <optional><attribute name="required"><choice><value>true</value><value>false</value></choice></attribute></optional>27 31 </define> 28 32 … … 35 39 <ref name="daodatasource" /> 36 40 </choice> 37 <!-- <optional> 38 <attribute name="appearance"> 39 <choice> 40 <value>full</value> checkbox /radiobox 41 <value>compact</value> listbox multiple /listbox 42 <value>minimal</value> listbox multiple / combobox 43 </choice> 44 </attribute> 45 </optional> --> 46 </define> 41 </define> 42 47 43 <define name="item"> 48 44 <element name="item"> … … 106 102 <ref name="output" /> 107 103 <ref name="upload" /> 108 <ref name="select1" />109 <ref name="select" />110 104 <ref name="submit" /> 105 <ref name="checkbox" /> 106 <ref name="checkboxes" /> 107 <ref name="listbox" /> 108 <ref name="radiobuttons"/> 109 <ref name="menulist" /> 111 110 <!-- 112 111 <ref name="range" /> … … 145 144 </element> 146 145 </define> 147 146 147 <define name="checkbox"> 148 <element name="checkbox"> 149 <ref name="UI.Common" /> 150 <ref name="UI.attr.readonly" /> 151 </element> 152 </define> 153 154 <!-- 148 155 <define name="select1"> 149 156 <element name="select1"> … … 153 160 <attribute name="appearance"> 154 161 <choice> 155 <value>full</value> 156 <value>radiobox</value> 157 <value>compact</value> 162 <value>radiobuttons</value> 158 163 <value>listbox</value> 159 <value>minimal</value>160 164 <value>menulist</value> 161 165 </choice> 162 166 </attribute> 163 167 </optional> 164 165 <!-- <optional> 166 <attribute name="selection"> 167 <choice> 168 <value>open</value> 169 <value>close</value> 170 </choice> 171 </attribute> 172 </optional>--> 173 </element> 174 </define> 175 176 177 <define name="select"> 168 </element> 169 </define> 170 --> 171 <define name="radiobuttons"> 172 <element name="radiobuttons"> 173 <ref name="UI.Common" /> 174 <ref name="List.UI.Common" /> 175 </element> 176 </define> 177 178 <define name="listbox"> 179 <element name="radiobuttons"> 180 <ref name="UI.Common" /> 181 <ref name="List.UI.Common" /> 182 <optional> 183 <attribute name="multiple"> 184 <choice><value>true</value><value>false</value></choice> 185 </attribute> 186 </optional> 187 </element> 188 </define> 189 190 <define name="menulist"> 191 <element name="radiobuttons"> 192 <ref name="UI.Common" /> 193 <ref name="List.UI.Common" /> 194 </element> 195 </define> 196 197 <!-- <define name="select"> 178 198 <element name="select"> 179 199 <ref name="UI.Common" /> … … 182 202 <attribute name="appearance"> 183 203 <choice> 184 <value>full</value>185 204 <value>checkbox</value> 186 <value>compact</value>187 205 <value>listbox</value> 188 206 </choice> 189 207 </attribute> 190 208 </optional> 191 <!--<optional>192 <attribute name="selection">193 <choice> 194 <value>open</value>195 <value>close</value>196 </choice>197 </attribute>198 </optional>-->199 </element>200 </define> 201 209 </element> 210 </define>--> 211 212 <define name="checkboxes"> 213 <element name="checkboxes"> 214 <ref name="UI.Common" /> 215 <ref name="List.UI.Common" /> 216 </element> 217 </define> 218 219 202 220 <define name="output"> 203 221 <element name="output"> branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng
r442 r453 23 23 <define name="UI.Common.data"> 24 24 <optional><ref name="datatypes" /></optional> 25 <ref name="UI.attr.readonly" /> 26 <optional><attribute name="required"><choice><value>true</value><value>false</value></choice></attribute></optional> 27 </define> 28 29 <define name="UI.attr.readonly"> 25 30 <optional><attribute name="readonly"><choice><value>true</value><value>false</value></choice></attribute></optional> 26 <optional><attribute name="required"><choice><value>true</value><value>false</value></choice></attribute></optional>27 31 </define> 28 32 … … 35 39 <ref name="daodatasource" /> 36 40 </choice> 37 <!-- <optional> 38 <attribute name="appearance"> 39 <choice> 40 <value>full</value> checkbox /radiobox 41 <value>compact</value> listbox multiple /listbox 42 <value>minimal</value> listbox multiple / combobox 43 </choice> 44 </attribute> 45 </optional> --> 46 </define> 41 </define> 42 47 43 <define name="item"> 48 44 <element name="item"> … … 106 102 <ref name="output" /> 107 103 <ref name="upload" /> 108 <ref name="select1" />109 <ref name="select" />110 104 <ref name="submit" /> 105 <ref name="checkbox" /> 106 <ref name="checkboxes" /> 107 <ref name="listbox" /> 108 <ref name="radiobuttons"/> 109 <ref name="menulist" /> 111 110 <!-- 112 111 <ref name="range" /> … … 145 144 </element> 146 145 </define> 147 146 147 <define name="checkbox"> 148 <element name="checkbox"> 149 <ref name="UI.Common" /> 150 <ref name="UI.attr.readonly" /> 151 </element> 152 </define> 153 154 <!-- 148 155 <define name="select1"> 149 156 <element name="select1"> … … 153 160 <attribute name="appearance"> 154 161 <choice> 155 <value>full</value> 156 <value>radiobox</value> 157 <value>compact</value> 162 <value>radiobuttons</value> 158 163 <value>listbox</value> 159 <value>minimal</value>160 164 <value>menulist</value> 161 165 </choice> 162 166 </attribute> 163 167 </optional> 164 165 <!-- <optional> 166 <attribute name="selection"> 167 <choice> 168 <value>open</value> 169 <value>close</value> 170 </choice> 171 </attribute> 172 </optional>--> 173 </element> 174 </define> 175 176 177 <define name="select"> 168 </element> 169 </define> 170 --> 171 <define name="radiobuttons"> 172 <element name="radiobuttons"> 173 <ref name="UI.Common" /> 174 <ref name="List.UI.Common" /> 175 </element> 176 </define> 177 178 <define name="listbox"> 179 <element name="radiobuttons"> 180 <ref name="UI.Common" /> 181 <ref name="List.UI.Common" /> 182 <optional> 183 <attribute name="multiple"> 184 <choice><value>true</value><value>false</value></choice> 185 </attribute> 186 </optional> 187 </element> 188 </define> 189 190 <define name="menulist"> 191 <element name="radiobuttons"> 192 <ref name="UI.Common" /> 193 <ref name="List.UI.Common" /> 194 </element> 195 </define> 196 197 <!-- <define name="select"> 178 198 <element name="select"> 179 199 <ref name="UI.Common" /> … … 182 202 <attribute name="appearance"> 183 203 <choice> 184 <value>full</value>185 204 <value>checkbox</value> 186 <value>compact</value>187 205 <value>listbox</value> 188 206 </choice> 189 207 </attribute> 190 208 </optional> 191 <!--<optional>192 <attribute name="selection">193 <choice> 194 <value>open</value>195 <value>close</value>196 </choice>197 </attribute>198 </optional>-->199 </element>200 </define> 201 209 </element> 210 </define>--> 211 212 <define name="checkboxes"> 213 <element name="checkboxes"> 214 <ref name="UI.Common" /> 215 <ref name="List.UI.Common" /> 216 </element> 217 </define> 218 219 202 220 <define name="output"> 203 221 <element name="output"> branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php
r452 r453 96 96 97 97 public function outputControlLabel($ctrl){ 98 if($ctrl->type == 'output' ){98 if($ctrl->type == 'output' || $ctrl->type == 'checkboxes'){ 99 99 echo htmlspecialchars($ctrl->label); 100 100 } … … 112 112 echo '<input type="text" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 113 113 break; 114 case 'select1': 114 case 'checkbox': 115 if($this->_form->getData($ctrl->ref)){ 116 $v=' checked="checked"'; 117 }else{ 118 $v=""; 119 } 120 echo '<input type="checkbox" ',$id,$readonly,$v,' value="true"/>'; 115 121 break; 116 case 'select': 122 /*case 'checkboxes': 123 $i=0; 124 $id=' name="'.$ctrl->ref.'[]" id="'.$this->_name.'_'.$ctrl->ref.'_'; 125 $value = $this->_form->getData($ctrl->ref); 126 foreach($ctrl->datasource->getDatas() as $v=>$label){ 127 $i++; 128 echo '<input type="checkbox"',$id,$i,'" value="',htmlspecialchars($v),'" checked="checked" /><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 129 } 130 break;*/ 131 case 'radiobuttons': 132 $i=0; 133 $id=' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'_'; 134 $value = $this->_form->getData($ctrl->ref); 135 foreach($ctrl->datasource->getDatas() as $v=>$label){ 136 $i++; 137 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'" ',($v==$value?'checked="checked"':''),' />'; 138 echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label>'; 139 } 140 break; 141 case 'menulist': 142 echo '<select ',$id,$readonly,' size="1">'; 143 $value = $this->_form->getData($ctrl->ref); 144 foreach($ctrl->datasource->getDatas() as $v=>$label){ 145 echo '<option value="',htmlspecialchars($v),'"',($v==$value?'selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 146 } 147 echo '</select>'; 148 break; 149 case 'listbox': 150 /*if($ctrl->multiple){ 151 echo '<select ',$id,$readonly,' size="3" multiple="multiple">'; 152 $value = $this->_form->getData($ctrl->ref); 153 foreach($ctrl->datasource->getDatas() as $v=>$label){ 154 echo '<option value="',htmlspecialchars($v),'"',($v==$value?'selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 155 } 156 echo '</select>'; 157 }else{*/ 158 echo '<select ',$id,$readonly,' size="4">'; 159 $value = $this->_form->getData($ctrl->ref); 160 foreach($ctrl->datasource->getDatas() as $v=>$label){ 161 echo '<option value="',htmlspecialchars($v),'"',($v==$value?'selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 162 } 163 echo '</select>'; 164 //} 117 165 break; 118 166 case 'textarea': branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php
r452 r453 96 96 97 97 public function outputControlLabel($ctrl){ 98 if($ctrl->type == 'output' ){98 if($ctrl->type == 'output' || $ctrl->type == 'checkboxes'){ 99 99 echo htmlspecialchars($ctrl->label); 100 100 } … … 112 112 echo '<input type="text" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 113 113 break; 114 case 'select1': 114 case 'checkbox': 115 if($this->_form->getData($ctrl->ref)){ 116 $v=' checked="checked"'; 117 }else{ 118 $v=""; 119 } 120 echo '<input type="checkbox" ',$id,$readonly,$v,' value="true"/>'; 115 121 break; 116 case 'select': 122 /*case 'checkboxes': 123 $i=0; 124 $id=' name="'.$ctrl->ref.'[]" id="'.$this->_name.'_'.$ctrl->ref.'_'; 125 $value = $this->_form->getData($ctrl->ref); 126 foreach($ctrl->datasource->getDatas() as $v=>$label){ 127 $i++; 128 echo '<input type="checkbox"',$id,$i,'" value="',htmlspecialchars($v),'" checked="checked" /><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 129 } 130 break;*/ 131 case 'radiobuttons': 132 $i=0; 133 $id=' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'_'; 134 $value = $this->_form->getData($ctrl->ref); 135 foreach($ctrl->datasource->getDatas() as $v=>$label){ 136 $i++; 137 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'" ',($v==$value?'checked="checked"':''),' />'; 138 echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label>'; 139 } 140 break; 141 case 'menulist': 142 echo '<select ',$id,$readonly,' size="1">'; 143 $value = $this->_form->getData($ctrl->ref); 144 foreach($ctrl->datasource->getDatas() as $v=>$label){ 145 echo '<option value="',htmlspecialchars($v),'"',($v==$value?'selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 146 } 147 echo '</select>'; 148 break; 149 case 'listbox': 150 /*if($ctrl->multiple){ 151 echo '<select ',$id,$readonly,' size="3" multiple="multiple">'; 152 $value = $this->_form->getData($ctrl->ref); 153 foreach($ctrl->datasource->getDatas() as $v=>$label){ 154 echo '<option value="',htmlspecialchars($v),'"',($v==$value?'selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 155 } 156 echo '</select>'; 157 }else{*/ 158 echo '<select ',$id,$readonly,' size="4">'; 159 $value = $this->_form->getData($ctrl->ref); 160 foreach($ctrl->datasource->getDatas() as $v=>$label){ 161 echo '<option value="',htmlspecialchars($v),'"',($v==$value?'selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 162 } 163 echo '</select>'; 164 //} 117 165 break; 118 166 case 'textarea': branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r452 r453 66 66 foreach($xml->children() as $controltype=>$control){ 67 67 $source[] = $this->generatePHPControl($controltype, $control); 68 $srcjs[] = $this->generateJsControl($control );68 $srcjs[] = $this->generateJsControl($controltype, $control); 69 69 } 70 70 $source[]=' }'; … … 111 111 } 112 112 $source[]='$ctrl->datatype= new jDatatype'.$dt.'();'; 113 }else if($controltype == 'checkbox') { 114 $source[]='$ctrl->datatype= new jDatatypeBoolean();'; 113 115 }else{ 114 116 $source[]='$ctrl->datatype= new jDatatypeString();'; … … 116 118 117 119 if(isset($control['readonly'])){ 118 $readonly=(string)$control['readonly']; 119 120 $source[]='$ctrl->readonly='.($readonly=='true'?'true':'false').';'; 120 if('true' == (string)$control['readonly']) 121 $source[]='$ctrl->readonly=true;'; 121 122 } 122 123 if(isset($control['required'])){ 123 $required=(string)$control['required']; 124 $source[]='$ctrl->required='.($required=='true'?'true':'false').';'; 124 if($controltype == 'checkbox'){ 125 throw new jException('jelix~formserr.attribute.not.allowed',array('required','checkbox',$this->sourceFile)); 126 } 127 if('true' == (string)$control['required']) 128 $source[]='$ctrl->required=true;'; 125 129 } 126 130 … … 140 144 141 145 switch($controltype){ 142 case 'select1': 143 case 'select': 146 case 'checkboxes': 147 case 'radiobuttons': 148 case 'menulist': 149 case 'listbox': 144 150 // recuperer les <items> attr label|labellocale value 145 151 if(isset($control['dao'])){ … … 169 175 break; 170 176 } 177 178 if(isset($control['multiple'])){ 179 if($controltype != 'listbox'){ 180 throw new jException('jelix~formserr.attribute.not.allowed',array('multiple',$controltype,$this->sourceFile)); 181 } 182 if('true' == (string)$control['multiple']) 183 $source[]='$ctrl->multiple=true;'; 184 } 185 171 186 $source[]='$this->addControl($ctrl);'; 172 173 187 return implode("\n", $source); 174 188 } 175 189 176 protected function generateJsControl($control ){190 protected function generateJsControl($controltype, $control){ 177 191 $source = array(); 178 192 … … 180 194 $dt = (string)$control['type']; 181 195 }else{ 182 $dt = 'string'; 196 if($controltype == 'checkbox') 197 $dt = 'boolean'; 198 else 199 $dt = 'string'; 183 200 } 184 201 … … 190 207 $source[]='$js.="gControl = new jFormsControl(\''.(string)$control['ref'].'\', \'".$label."\', \''.$dt.'\');\n";'; 191 208 192 if(isset($control['readonly'])){ 193 $readonly=(string)$control['readonly']; 194 $source[]='$js.="gControl.readonly = '.($readonly=='true'?'true':'false').';\n";'; 195 } 196 if(isset($control['required'])){ 197 $required=(string)$control['required']; 198 $source[]='$js.="gControl.required = '.($required=='true'?'true':'false').';\n";'; 209 if(isset($control['readonly']) && 'true' == (string)$control['readonly']){ 210 $source[]='$js.="gControl.readonly = true;\n";'; 211 } 212 if(isset($control['required']) && 'true' == (string)$control['required']){ 213 $source[]='$js.="gControl.required = true;\n";'; 199 214 } 200 215 201 216 $source[]='$js.="gControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";'; 202 217 $source[]='$js.="gControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";'; 203 204 /* 205 switch($controltype){ 206 case 'secret': 207 break; 208 case 'output': 209 //attr value 210 break; 211 case 'upload': 212 // attr mediatype 213 break; 214 case 'select1': 215 case 'select': 216 // recuperer les <items> attr label|labellocale value 217 if(isset($control['dao'])){ 218 $daoselector = (string)$control['dao']; 219 $daomethod = (string)$control['daomethod']; 220 $daolabel = (string)$control['daolabelproperty']; 221 $daovalue = (string)$control['daovalueproperty']; 222 $source[]='$ctrl->datasource = new jFormDaoDatasource(\''.$daoselector.'\',\''. 223 $daomethod.'\',\''.$daolabel.'\',\''.$daovalue.'\',);'; 224 225 }else{ 226 $source[]='$ctrl->datasource= new jFormStaticDatasource();'; 227 $source[]='$ctrl->datasource->array('; 228 229 foreach($control->item as $item){ 230 $value ="'".str_replace("'","\\'",(string)$item['value'])."'=>"; 231 if(isset($item['label'])){ 232 $source[] = $value."'".str_replace("'","\\'",(string)$item['label'])."',"; 233 }elseif(isset($item['labellocale'])){ 234 $source[] = $value."jLocale::get('".(string)$item['labellocale']."'),"; 235 }else{ 236 $source[] = $value."'".str_replace("'","\\'",(string)$item['value'])."',"; 237 } 238 } 239 $source[]=");"; 240 } 241 break; 242 case 'submit': 243 // attr value 244 break; 245 }*/ 218 if(isset($control['multiple']) && 'true' == (string)$control['multiple']){ 219 $source[]='$js.="gControl.multiple = true;\n";'; 220 } 221 246 222 $source[]='$js.="gForm.addControl( gControl);\n";'; 247 223 248 224 return implode("\n", $source); 249 250 251 225 } 252 226 branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r452 r453 66 66 foreach($xml->children() as $controltype=>$control){ 67 67 $source[] = $this->generatePHPControl($controltype, $control); 68 $srcjs[] = $this->generateJsControl($control );68 $srcjs[] = $this->generateJsControl($controltype, $control); 69 69 } 70 70 $source[]=' }'; … … 111 111 } 112 112 $source[]='$ctrl->datatype= new jDatatype'.$dt.'();'; 113 }else if($controltype == 'checkbox') { 114 $source[]='$ctrl->datatype= new jDatatypeBoolean();'; 113 115 }else{ 114 116 $source[]='$ctrl->datatype= new jDatatypeString();'; … … 116 118 117 119 if(isset($control['readonly'])){ 118 $readonly=(string)$control['readonly']; 119 120 $source[]='$ctrl->readonly='.($readonly=='true'?'true':'false').';'; 120 if('true' == (string)$control['readonly']) 121 $source[]='$ctrl->readonly=true;'; 121 122 } 122 123 if(isset($control['required'])){ 123 $required=(string)$control['required']; 124 $source[]='$ctrl->required='.($required=='true'?'true':'false').';'; 124 if($controltype == 'checkbox'){ 125 throw new jException('jelix~formserr.attribute.not.allowed',array('required','checkbox',$this->sourceFile)); 126 } 127 if('true' == (string)$control['required']) 128 $source[]='$ctrl->required=true;'; 125 129 } 126 130 … … 140 144 141 145 switch($controltype){ 142 case 'select1': 143 case 'select': 146 case 'checkboxes': 147 case 'radiobuttons': 148 case 'menulist': 149 case 'listbox': 144 150 // recuperer les <items> attr label|labellocale value 145 151 if(isset($control['dao'])){ … … 169 175 break; 170 176 } 177 178 if(isset($control['multiple'])){ 179 if($controltype != 'listbox'){ 180 throw new jException('jelix~formserr.attribute.not.allowed',array('multiple',$controltype,$this->sourceFile)); 181 } 182 if('true' == (string)$control['multiple']) 183 $source[]='$ctrl->multiple=true;'; 184 } 185 171 186 $source[]='$this->addControl($ctrl);'; 172 173 187 return implode("\n", $source); 174 188 } 175 189 176 protected function generateJsControl($control ){190 protected function generateJsControl($controltype, $control){ 177 191 $source = array(); 178 192 … … 180 194 $dt = (string)$control['type']; 181 195 }else{ 182 $dt = 'string'; 196 if($controltype == 'checkbox') 197 $dt = 'boolean'; 198 else 199 $dt = 'string'; 183 200 } 184 201 … … 190 207 $source[]='$js.="gControl = new jFormsControl(\''.(string)$control['ref'].'\', \'".$label."\', \''.$dt.'\');\n";'; 191 208 192 if(isset($control['readonly'])){ 193 $readonly=(string)$control['readonly']; 194 $source[]='$js.="gControl.readonly = '.($readonly=='true'?'true':'false').';\n";'; 195 } 196 if(isset($control['required'])){ 197 $required=(string)$control['required']; 198 $source[]='$js.="gControl.required = '.($required=='true'?'true':'false').';\n";'; 209 if(isset($control['readonly']) && 'true' == (string)$control['readonly']){ 210 $source[]='$js.="gControl.readonly = true;\n";'; 211 } 212 if(isset($control['required']) && 'true' == (string)$control['required']){ 213 $source[]='$js.="gControl.required = true;\n";'; 199 214 } 200 215 201 216 $source[]='$js.="gControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";'; 202 217 $source[]='$js.="gControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";'; 203 204 /* 205 switch($controltype){ 206 case 'secret': 207 break; 208 case 'output': 209 //attr value 210 break; 211 case 'upload': 212 // attr mediatype 213 break; 214 case 'select1': 215 case 'select': 216 // recuperer les <items> attr label|labellocale value 217 if(isset($control['dao'])){ 218 $daoselector = (string)$control['dao']; 219 $daomethod = (string)$control['daomethod']; 220 $daolabel = (string)$control['daolabelproperty']; 221 $daovalue = (string)$control['daovalueproperty']; 222 $source[]='$ctrl->datasource = new jFormDaoDatasource(\''.$daoselector.'\',\''. 223 $daomethod.'\',\''.$daolabel.'\',\''.$daovalue.'\',);'; 224 225 }else{ 226 $source[]='$ctrl->datasource= new jFormStaticDatasource();'; 227 $source[]='$ctrl->datasource->array('; 228 229 foreach($control->item as $item){ 230 $value ="'".str_replace("'","\\'",(string)$item['value'])."'=>"; 231 if(isset($item['label'])){ 232 $source[] = $value."'".str_replace("'","\\'",(string)$item['label'])."',"; 233 }elseif(isset($item['labellocale'])){ 234 $source[] = $value."jLocale::get('".(string)$item['labellocale']."'),"; 235 }else{ 236 $source[] = $value."'".str_replace("'","\\'",(string)$item['value'])."',"; 237 } 238 } 239 $source[]=");"; 240 } 241 break; 242 case 'submit': 243 // attr value 244 break; 245 }*/ 218 if(isset($control['multiple']) && 'true' == (string)$control['multiple']){ 219 $source[]='$js.="gControl.multiple = true;\n";'; 220 } 221 246 222 $source[]='$js.="gForm.addControl( gControl);\n";'; 247 223 248 224 return implode("\n", $source); 249 250 251 225 } 252 226 branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php
r442 r453 63 63 * @experimental 64 64 */ 65 class jFormsControlSelect extends jFormsControlSelect1 {65 /*class jFormsControlSelect extends jFormsControlSelect1 { 66 66 public $type="select"; 67 }*/ 68 69 /** 70 * 71 * @package jelix 72 * @subpackage forms 73 * @experimental 74 */ 75 class jFormsControlCheckboxes extends jFormsControlSelect1 { 76 public $type="checkboxes"; 77 } 78 79 /** 80 * 81 * @package jelix 82 * @subpackage forms 83 * @experimental 84 */ 85 class jFormsControlRadiobuttons extends jFormsControlSelect1 { 86 public $type="radiobuttons"; 87 } 88 89 /** 90 * 91 * @package jelix 92 * @subpackage forms 93 * @experimental 94 */ 95 class jFormsControlListbox extends jFormsControlSelect1 { 96 public $type="listbox"; 97 public $multiple = false; 98 } 99 100 /** 101 * 102 * @package jelix 103 * @subpackage forms 104 * @experimental 105 */ 106 class jFormsControlMenulist extends jFormsControlSelect1 { 107 public $type="menulist"; 67 108 } 68 109 … … 85 126 class jFormsControlSecret extends jFormsControl { 86 127 public $type='secret'; 128 } 129 130 /** 131 * 132 * @package jelix 133 * @subpackage forms 134 * @experimental 135 */ 136 class jFormsControlCheckbox extends jFormsControl { 137 public $type='checkbox'; 87 138 } 88 139 branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php
r442 r453 63 63 * @experimental 64 64 */ 65 class jFormsControlSelect extends jFormsControlSelect1 {65 /*class jFormsControlSelect extends jFormsControlSelect1 { 66 66 public $type="select"; 67 }*/ 68 69 /** 70 * 71 * @package jelix 72 * @subpackage forms 73 * @experimental 74 */ 75 class jFormsControlCheckboxes extends jFormsControlSelect1 { 76 public $type="checkboxes"; 77 } 78 79 /** 80 * 81 * @package jelix 82 * @subpackage forms 83 * @experimental 84 */ 85 class jFormsControlRadiobuttons extends jFormsControlSelect1 { 86 public $type="radiobuttons"; 87 } 88 89 /** 90 * 91 * @package jelix 92 * @subpackage forms 93 * @experimental 94 */ 95 class jFormsControlListbox extends jFormsControlSelect1 { 96 public $type="listbox"; 97 public $multiple = false; 98 } 99 100 /** 101 * 102 * @package jelix 103 * @subpackage forms 104 * @experimental 105 */ 106 class jFormsControlMenulist extends jFormsControlSelect1 { 107 public $type="menulist"; 67 108 } 68 109 … … 85 126 class jFormsControlSecret extends jFormsControl { 86 127 public $type='secret'; 128 } 129 130 /** 131 * 132 * @package jelix 133 * @subpackage forms 134 * @experimental 135 */ 136 class jFormsControlCheckbox extends jFormsControl { 137 public $type='checkbox'; 87 138 } 88 139 branches/experimental/jforms/lib/jelix/forms/jFormsDatasource.class.php
r324 r453 57 57 public function getDatas(){ 58 58 $dao = jDao::get($this->daoselector); 59 $found = $dao-> ${$this->daomethod}();
