Skip to content

Commit b15fe79

Browse files
committed
checkboxes bug fixed + dd setPropertyValues
1 parent 34fb156 commit b15fe79

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

Ajax/semantic/html/collections/form/HtmlFormFields.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function radios($name, $items=array(), $label=NULL, $value=null, $
103103
foreach ( $items as $val => $caption ) {
104104
$itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type);
105105
if ($val===$value) {
106-
$itemO->getField()->setProperty("checked", "");
106+
$itemO->getDataField()->setProperty("checked", "");
107107
}
108108
$fields[]=$itemO;
109109
}
@@ -117,9 +117,10 @@ public static function checkeds($name, $items=array(), $label=NULL, $values=arra
117117
$fields=array ();
118118
$i=0;
119119
foreach ( $items as $val => $caption ) {
120-
$itemO=new HtmlFormCheckbox($name."-".$i++, $name, $caption, $val, $type);
120+
$itemO=new HtmlFormCheckbox($name."-".$i++, $caption, $val, $type);
121+
$itemO->setName($name);
121122
if (\array_search($val, $values)!==false) {
122-
$itemO->getField()->getDataField()->setProperty("checked", "");
123+
$itemO->getDataField()->setProperty("checked", "");
123124
}
124125
$fields[]=$itemO;
125126
}

Ajax/semantic/html/modules/HtmlDropdown.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,29 @@ public function addItems($items){
186186
}
187187
}
188188

189+
/**
190+
* Sets the values of a property for each item in the collection
191+
* @param string $property
192+
* @param array $values
193+
* @return HtmlCollection
194+
*/
195+
public function setPropertyValues($property,$values){
196+
$i=0;
197+
if(\is_array($values)===false){
198+
$values=\array_fill(0, $this->count(),$values);
199+
}
200+
foreach ($values as $value){
201+
$c=$this->items[$i++];
202+
if(isset($c)){
203+
$c->setProperty($property,$value);
204+
}
205+
else{
206+
return $this;
207+
}
208+
}
209+
return $this;
210+
}
211+
189212
public function getItem($index){
190213
return $this->items[$index];
191214
}

0 commit comments

Comments
 (0)