From b41c6824c5a2d7dac80344ced53b55192da9c844 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 8 Mar 2015 23:29:16 +0100 Subject: [PATCH] Let text inputs have placeholder values. --- lib/htmloutputter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 9e9dc02e59..3409ff8f92 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -198,6 +198,14 @@ class HTMLOutputter extends XMLOutputter } $attrs['id'] = $id; $attrs['name'] = is_null($name) ? $id : $name; + if (array_key_exists('placeholder', $attrs) && (is_null($attrs['placeholder']) || $attrs['placeholder'] === '')) { + // If placeholder is type-aware equal to '' or null, unset it as we apparently don't want a placeholder value + unset($attrs['placeholder']); + } else { + // If the placeholder is set use it, or use the label as fallback. + $attrs['placeholder'] = isset($attrs['placeholder']) ? $attrs['placeholder'] : $label; + } + if (!is_null($value)) { // value can be 0 or '' $attrs['value'] = $value; } -- 2.39.5