From 79fa81d8a87a1d026d8f763021b8df191f48a4e0 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 21 May 2018 09:23:47 -0400 Subject: [PATCH] Add enhancement processwire/processwire-issues#596 show field labels rather than field names in Inputfield error messages --- wire/core/Inputfield.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wire/core/Inputfield.php b/wire/core/Inputfield.php index fe337618..1ebe5ad7 100644 --- a/wire/core/Inputfield.php +++ b/wire/core/Inputfield.php @@ -1458,7 +1458,9 @@ abstract class Inputfield extends WireData implements Module { $errors[] = $text; $this->wire('session')->set($key, $errors); } - $text .= $this->name ? " ($this->name)" : ""; + $label = $this->getSetting('label'); + if(empty($label)) $label= $this->attr('name'); + if(strlen($label)) $text .= " - $label"; return parent::error($text, $flags); }