Skip to content

Commit b889042

Browse files
committed
fieldasCheckbox bug fixed
To fix : labeled button
1 parent 462f88b commit b889042

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

Ajax/common/html/traits/BaseHtmlEventsTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* @author jc
1111
* @property SimpleExtComponent $_bsComponent
1212
* @property string identifier
13+
* @property BaseHtml _self
1314
*/
1415
trait BaseHtmlEventsTrait{
1516

@@ -20,7 +21,7 @@ trait BaseHtmlEventsTrait{
2021
* @param string|AjaxCall $jsCode
2122
* @param boolean $stopPropagation
2223
* @param boolean $preventDefault
23-
* @return \Ajax\common\html\BaseHtml
24+
* @return BaseHtml
2425
*/
2526
public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
2627
if ($stopPropagation === true) {
@@ -55,10 +56,10 @@ public function _addEvent($event, $jsCode) {
5556
* @param string $jsCode
5657
* @param boolean $stopPropagation
5758
* @param boolean $preventDefault
58-
* @return \Ajax\common\html\BaseHtml
59+
* @return BaseHtml
5960
*/
6061
public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
61-
return $this->addEvent($event, $jsCode, $stopPropagation, $preventDefault);
62+
return $this->_self->addEvent($event, $jsCode, $stopPropagation, $preventDefault);
6263
}
6364

6465
public function onClick($jsCode, $stopPropagation=false, $preventDefault=true) {

Ajax/semantic/html/elements/HtmlButton.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ public function asSubmit() {
105105
* @return HtmlLabel
106106
*/
107107
public function addLabel($label, $before=false, $icon=NULL) {
108-
$this->tagName="div";
109-
$this->addToProperty("class", "labeled");
108+
$this->tagName="div";$prefix="";
109+
if($before)
110+
$prefix="left ";
111+
$this->addToProperty("class", $prefix."labeled");
110112
$this->content=new HtmlButton("button-" . $this->identifier, $this->content);
111113
$this->content->setTagName("div");
112114
$label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a");
@@ -135,6 +137,19 @@ public function setPositive() {
135137
return $this->addToProperty("class", "positive");
136138
}
137139

140+
public function setColor($color){
141+
//TODO check button content
142+
if(\is_array($this->content)){
143+
foreach ($this->content as $content){
144+
if($content instanceof HtmlButton)
145+
$content->setColor($color);
146+
}
147+
}
148+
else
149+
parent::setColor($color);
150+
return $this;
151+
}
152+
138153
/**
139154
* hint towards a negative consequence
140155
* @return HtmlButton

Ajax/semantic/html/elements/HtmlHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class HtmlHeader extends HtmlSemDoubleElement {
1515

1616
public function __construct($identifier, $niveau=1, $content=NULL, $type="page") {
1717
parent::__construct($identifier, "div", "ui header");
18-
$this->_template="<%tagName% %properties%>%image%%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>";
18+
$this->_template="<%tagName% id='%identifier%' %properties%>%image%%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>";
1919
if (isset($type)) {
2020
if ($type == "page") {
2121
$this->asPageHeader($niveau);

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ public function fieldAsHidden($index,$attributes=NULL){
194194

195195
public function fieldAsCheckbox($index,$attributes=NULL){
196196
return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){
197+
if($caption===null || $caption==="")
198+
$caption="";
197199
$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
198200
$input->setChecked(JString::isBooleanTrue($value));
199201
return $this->_prepareFormFields($input, $name, $attributes);

0 commit comments

Comments
 (0)