Show the default value in Config.

Summary:
As mentioned by @epriestley in an inline on D4290, we should show what happens
if the user leaves the box blank.

Test Plan: Went to edit a setting and saw the default below the text box.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, asherkin

Differential Revision: https://secure.phabricator.com/D4293
This commit is contained in:
Ricky Elrod
2012-12-28 11:37:55 -08:00
committed by epriestley
parent a774620042
commit a9aedc64e4
2 changed files with 36 additions and 10 deletions

View File

@@ -24,4 +24,20 @@ abstract class PhabricatorConfigController extends PhabricatorController {
return $crumbs;
}
/**
* Properly format a JSON value.
*
* @param wild Any value, but should be a raw value, not a string of JSON.
* @return string
*/
public function prettyPrintJSON($value) {
// Check not only that it's an array, but that it's an "unnatural" array
// meaning that the keys aren't 0 -> size_of_array.
if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) {
return id(new PhutilJSON())->encodeFormatted($value);
} else {
return json_encode($value);
}
}
}