Ticket #582: jelix-trunk-#582.2.patch
| File jelix-trunk-#582.2.patch, 5.3 kB (added by bibo, 8 months ago) |
|---|
-
lib/jelix/docs/ns/jforms_1.1.rng
old new 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <grammar 2 <grammar 3 3 xmlns="http://relaxng.org/ns/structure/1.0" 4 4 xmlns:ev="http://www.w3.org/2001/xml-events" 5 5 datatype="http://www.w3.org/2001/XMLSchema-datatypes" … … 136 136 <optional><attribute name="maxsize"><data type="integer" /></attribute></optional> 137 137 <!--<element name="storage"> 138 138 <attribute name="type"><choice><value>file</value><value>blob</value></choice></attribute> 139 <attribute name="value" /> 139 <attribute name="value" /> 140 140 </element> 141 141 --> 142 142 </element> 143 143 </define> 144 144 145 145 <define name="checkbox"> 146 146 <element name="checkbox"> 147 147 <ref name="control.common" /> … … 231 231 <ref name="alert" /> 232 232 </optional> 233 233 </define> 234 234 235 235 <define name="UI.attr.readonly"> 236 236 <optional><attribute name="readonly"><choice><value>true</value><value>false</value></choice></attribute></optional> 237 237 </define> … … 241 241 <define name="UI.attr.defaultvalue"> 242 242 <optional><attribute name="defaultvalue" /></optional> 243 243 </define> 244 244 245 245 <define name="attr.length"> 246 246 <optional><attribute name="minlength"><data type="integer" /></attribute></optional> 247 247 <optional><attribute name="maxlength"><data type="integer" /></attribute></optional> … … 319 319 <attribute name="criteriafrom" /> 320 320 </choice> 321 321 </optional> 322 <optional><attribute name="profile" /></optional> 322 323 </group> 323 324 <attribute name="class" /> 324 325 </choice> … … 393 394 </define> 394 395 395 396 --> 396 397 397 398 398 399 </grammar> -
lib/jelix/forms/jFormsCompiler_jf_1_1.class.php
old new 101 101 } 102 102 103 103 if(isset($attrs['dao'])) { 104 if ( isset($attrs['profile'])) 105 $profile = '\''.$attrs['profile'].'\''; 106 else 107 $profile = '\'\''; 104 108 if(isset($attrs['valueproperty'])) { 105 109 $daovalue = $attrs['valueproperty']; 106 110 } else … … 117 121 else 118 122 $criteria=''; 119 123 120 $source[]='$ctrl->datasource = new jFormsDaoDatasource(\''.$attrs['dao'].'\', \''.124 $source[]='$ctrl->datasource = new jFormsDaoDatasource(\''.$attrs['dao'].'\','.$profile.',\''. 121 125 $attrs['method'].'\',\''.$attrs['labelproperty'].'\',\''.$daovalue.'\''.$criteria.');'; 122 126 if($controltype == 'submit'){ 123 127 $source[]='$ctrl->standalone=false;'; -
lib/jelix/forms/jFormsDatasource.class.php
old new 3 3 * @package jelix 4 4 * @subpackage forms 5 5 * @author Laurent Jouanneau 6 * @contributor 6 * @contributor Dominique Papin 7 7 * @copyright 2006-2007 Laurent Jouanneau 8 * @copyright 2008 Dominique Papin 8 9 * @link http://www.jelix.org 9 10 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 10 11 */ … … 17 18 */ 18 19 interface jIFormsDatasource { 19 20 /** 20 * load and returns data to fill a control. The returned array should be 21 * load and returns data to fill a control. The returned array should be 21 22 * an associative array key => label 22 23 * @param jFormsBase $form the form 23 24 * @return array the data … … 26 27 27 28 /** 28 29 * Return the label corresponding to the given key 29 * @param string $key the key 30 * @param string $key the key 30 31 * @return string the label 31 32 */ 32 33 public function getLabel($key); … … 85 86 86 87 protected $dao = null; 87 88 88 function __construct ($selector ,$method , $label, $key, $criteria=null, $criteriaFrom=null){ 89 $this->selector = $selector; 89 function __construct ($selector, $profile, $method , $label, $key, $criteria=null, $criteriaFrom=null){ 90 $this->selector = $selector; 91 $this->profile = $profile; 90 92 $this->method = $method ; 91 93 $this->labelProperty = $label; 92 94 $this->criteria = $criteria; 93 95 $this->criteriaFrom = $criteriaFrom; 94 96 if($key == ''){ 95 $rec = jDao::createRecord($this->selector );97 $rec = jDao::createRecord($this->selector, $this->profile); 96 98 $pfields = $rec->getPrimaryKeyNames(); 97 99 $key = $pfields[0]; 98 100 } … … 101 103 102 104 public function getData($form){ 103 105 if($this->dao === null) 104 $this->dao = jDao::get($this->selector );106 $this->dao = jDao::get($this->selector, $this->profile); 105 107 if($this->criteria !== null) { 106 108 $found = $this->dao->{$this->method}($this->criteria); 107 109 } else if ($this->criteriaFrom !== null) { … … 126 128 } 127 129 128 130 } 129
