From 0a790cfb430ba9039d9dc3fd70231c3591ae8602 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 12 Oct 2017 09:44:25 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#399 where InputfieldInteger wasn't supporting defaultValue --- wire/modules/Inputfield/InputfieldInteger.module | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wire/modules/Inputfield/InputfieldInteger.module b/wire/modules/Inputfield/InputfieldInteger.module index fd3801d2..7656c2ae 100644 --- a/wire/modules/Inputfield/InputfieldInteger.module +++ b/wire/modules/Inputfield/InputfieldInteger.module @@ -30,6 +30,7 @@ class InputfieldInteger extends Inputfield { $this->attr('max', ''); // blank means not set $this->attr('size', '10'); $this->set('initValue', ''); + $this->set('defaultValue', ''); } public function ___render() { @@ -57,11 +58,17 @@ class InputfieldInteger extends Inputfield { if($attrs['type'] == 'text') unset($attrs['step'], $attrs['min'], $attrs['max']); if($note) $note = " $note"; - if(!strlen($attrs['value']) && strlen($this->initValue)) { - $attrs['value'] = (int) $this->initValue; + + if(!strlen($attrs['value'])) { + if(strlen($this->initValue)) { + $attrs['value'] = (int) $this->initValue; // Inputfield-only version + } else if(strlen($this->defaultValue)) { + $attrs['value'] = (int) $this->defaultValue; // Fieldtype version + } } $out = "getAttributesString($attrs) . " />"; // . $note; + return $out; } @@ -128,7 +135,7 @@ class InputfieldInteger extends Inputfield { public function getConfigInputfields() { $inputfields = parent::getConfigInputfields(); - + $f = $this->wire('modules')->get('InputfieldRadios'); $f->attr('name', 'inputType'); $f->label = $this->_('Numeric Input Type');