Skip to content

Commit

Permalink
Fix StdClass bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheron committed Apr 15, 2018
1 parent c1ff00d commit e92b4f3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Ubiquity/controllers/admin/UbiquityMyAdminViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,17 @@ private function labeledInput($input,$value){
return $input;
}

private function _cleanStdClassValue($value){
if($value instanceof \stdClass){
$value=(array) $value;
}
if(is_array($value)){
$value=UArray::asPhpArray($value,"array");
}
$value=str_replace('"', "'", $value);
return $value;
}

public function getConfigDataForm($config) {
$de = $this->jquery->semantic ()->dataElement ( "frmDeConfig", $config );
$keys=array_keys($config);
Expand Down Expand Up @@ -661,8 +672,7 @@ public function getConfigDataForm($config) {
$drivers=Database::getAvailableDrivers();
$dbDe = new DataElement ( "de-database", $v );
$dbDe->setDefaultValueFunction(function($name,$value){
if(is_array($value))
$value=UArray::asPhpArray($value,"array");
$value=$this->_cleanStdClassValue($value);
$input= new HtmlFormInput("database-".$name,null,"text",$value);
return $this->labeledInput($input, $value);
});
Expand Down Expand Up @@ -693,10 +703,9 @@ public function getConfigDataForm($config) {
$de->setValueFunction("cache", function ($v, $instance, $index) {
$dbDe = new DataElement ( "de-cache", $v );
$dbDe->setDefaultValueFunction(function($name,$value){
if(is_array($value))
$value=UArray::asPhpArray($value,"array");
$input= new HtmlFormInput("cache-".$name,null,"text",$value);
return $this->labeledInput($input, $value);
$value=$this->_cleanStdClassValue($value);
$input= new HtmlFormInput("cache-".$name,null,"text",$value);
return $this->labeledInput($input, $value);
});
$dbDe->setFields ( [ "directory","system","params" ] );
$dbDe->setCaptions ( [ "directory","system","params" ] );
Expand Down

0 comments on commit e92b4f3

Please sign in to comment.