Commit 155839f9 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(core) Fix %askme% support for BooleanAttribute

issue #5897
Showing with 12 additions and 5 deletions
+12 -5
...@@ -50,15 +50,24 @@ class BooleanAttribute extends Attribute ...@@ -50,15 +50,24 @@ class BooleanAttribute extends Attribute
$this->templatable = $bool; $this->templatable = $bool;
} }
protected function isTemplatable()
{
/* Allow to set to %askme% if we are not (de)activating other fields */
return (!$this->submitForm && empty($this->managedAttributes) && $this->templatable);
}
function inputValue ($value) function inputValue ($value)
{ {
if ($this->isTemplate() && $this->isTemplatable() && ($value == '%askme%')) {
return $value;
}
return ($value == $this->trueValue); return ($value == $this->trueValue);
} }
function loadPostValue () function loadPostValue ()
{ {
if ($this->isVisible()) { if ($this->isVisible()) {
if ($this->isTemplate() && !$this->submitForm && empty($this->managedAttributes)) { if ($this->isTemplate() && $this->isTemplatable()) {
if (!isset($_POST[$this->getHtmlId()])) { if (!isset($_POST[$this->getHtmlId()])) {
$this->setPostValue(FALSE); $this->setPostValue(FALSE);
} elseif ($_POST[$this->getHtmlId()] == '%askme%') { } elseif ($_POST[$this->getHtmlId()] == '%askme%') {
...@@ -74,7 +83,7 @@ class BooleanAttribute extends Attribute ...@@ -74,7 +83,7 @@ class BooleanAttribute extends Attribute
function computeLdapValue () function computeLdapValue ()
{ {
if ($this->isTemplate() && ($this->value == '%askme%')) { if ($this->isTemplate() && $this->isTemplatable() && ($this->value == '%askme%')) {
return $this->value; return $this->value;
} else { } else {
return ($this->value ? $this->trueValue : $this->falseValue); return ($this->value ? $this->trueValue : $this->falseValue);
...@@ -98,9 +107,7 @@ class BooleanAttribute extends Attribute ...@@ -98,9 +107,7 @@ class BooleanAttribute extends Attribute
function renderTemplateInput () function renderTemplateInput ()
{ {
if (!$this->submitForm && empty($this->managedAttributes) && $this->templatable) { if ($this->isTemplatable()) {
/* Allow to set to %askme% if we are not (de)activating other fields */
$id = $this->getHtmlId(); $id = $this->getHtmlId();
if ($this->getValue() == '%askme%') { if ($this->getValue() == '%askme%') {
$selected = '%askme%'; $selected = '%askme%';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment