Skip to content

Commit dcc4d79

Browse files
committed
Add forceValue to checkbox
1 parent fdcf957 commit dcc4d79

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

Ajax/common/html/html5/HtmlInput.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
2-
32
namespace Ajax\common\html\html5;
43

54
use Ajax\common\html\HtmlSingleElement;
65
use Ajax\service\JString;
76
use Ajax\JsUtils;
87

98
class HtmlInput extends HtmlSingleElement {
9+
1010
protected $_placeholder;
11-
public function __construct($identifier,$type="text",$value=NULL,$placeholder=NULL) {
11+
12+
public function __construct($identifier, $type = "text", $value = NULL, $placeholder = NULL) {
1213
parent::__construct($identifier, "input");
1314
$this->setProperty("name", $identifier);
1415
$this->setValue($value);
@@ -17,28 +18,34 @@ public function __construct($identifier,$type="text",$value=NULL,$placeholder=NU
1718
}
1819

1920
public function setValue($value) {
20-
if(isset($value))
21-
$this->setProperty("value", $value);
21+
if (isset($value))
22+
$this->setProperty("value", $value);
2223
return $this;
2324
}
2425

2526
public function setInputType($value) {
2627
return $this->setProperty("type", $value);
2728
}
2829

29-
public function setPlaceholder($value){
30-
if(JString::isNotNull($value))
31-
$this->_placeholder=$value;
30+
public function forceValue($value = 'true') {
31+
$this->wrap('<input type="hidden" value="false" name="' . $this->identifier . '"/>');
32+
$this->setValue($value);
33+
return $this;
34+
}
35+
36+
public function setPlaceholder($value) {
37+
if (JString::isNotNull($value))
38+
$this->_placeholder = $value;
3239
return $this;
3340
}
3441

35-
public function compile(JsUtils $js=NULL,&$view=NULL){
36-
$value=$this->_placeholder;
37-
if(JString::isNull($value)){
38-
if(JString::isNotNull($this->getProperty("name")))
39-
$value=\ucfirst($this->getProperty("name"));
42+
public function compile(JsUtils $js = NULL, &$view = NULL) {
43+
$value = $this->_placeholder;
44+
if (JString::isNull($value)) {
45+
if (JString::isNotNull($this->getProperty("name")))
46+
$value = \ucfirst($this->getProperty("name"));
4047
}
4148
$this->setProperty("placeholder", $value);
42-
return parent::compile($js,$view);
49+
return parent::compile($js, $view);
4350
}
4451
}

Ajax/semantic/html/modules/HtmlDropdown.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ public function setValue($value) {
356356

357357
public function setDefaultText($text) {
358358
$this->content["text"] = new HtmlSemDoubleElement("", "div", "default text", $text);
359+
return $this;
359360
}
360361

361362
private function applyValue() {
@@ -394,22 +395,27 @@ public function setCompact() {
394395

395396
public function setAction($action) {
396397
$this->_params["action"] = $action;
398+
return $this;
397399
}
398400

399401
public function setOn($on) {
400402
$this->_params["on"] = $on;
403+
return $this;
401404
}
402405

403406
public function setShowOnFocus($value) {
404407
$this->_params["showOnFocus"] = $value;
408+
return $this;
405409
}
406410

407411
public function setAllowAdditions($value) {
408412
$this->_params["allowAdditions"] = $value;
413+
return $this;
409414
}
410415

411416
public function setFullTextSearch($value) {
412417
$this->_params["fullTextSearch"] = $value;
418+
return $this;
413419
}
414420

415421
public function compile(JsUtils $js = NULL, &$view = NULL) {
@@ -434,6 +440,7 @@ public function jsAddItem($caption, $value = null) {
434440

435441
public function setClearable($value) {
436442
$this->_params["clearable"] = $value;
443+
return $this;
437444
}
438445

439446
/**

Ajax/semantic/html/modules/checkbox/AbstractCheckbox.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public function setChecked($value = true) {
2929
return $this;
3030
}
3131

32+
public function forceValue($value = 'true') {
33+
$this->getField()->forceValue($value);
34+
return $this;
35+
}
36+
3237
public function setType($checkboxType) {
3338
return $this->addToPropertyCtrl("class", $checkboxType, CheckboxType::getConstants());
3439
}

0 commit comments

Comments
 (0)