mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 01:34:31 +02:00
Fix issue processwire/processwire-issues#399 where InputfieldInteger wasn't supporting defaultValue
This commit is contained in:
@@ -30,6 +30,7 @@ class InputfieldInteger extends Inputfield {
|
|||||||
$this->attr('max', ''); // blank means not set
|
$this->attr('max', ''); // blank means not set
|
||||||
$this->attr('size', '10');
|
$this->attr('size', '10');
|
||||||
$this->set('initValue', '');
|
$this->set('initValue', '');
|
||||||
|
$this->set('defaultValue', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ___render() {
|
public function ___render() {
|
||||||
@@ -57,11 +58,17 @@ class InputfieldInteger extends Inputfield {
|
|||||||
if($attrs['type'] == 'text') unset($attrs['step'], $attrs['min'], $attrs['max']);
|
if($attrs['type'] == 'text') unset($attrs['step'], $attrs['min'], $attrs['max']);
|
||||||
|
|
||||||
if($note) $note = " <span class='details'>$note</span>";
|
if($note) $note = " <span class='details'>$note</span>";
|
||||||
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 = "<input " . $this->getAttributesString($attrs) . " />"; // . $note;
|
$out = "<input " . $this->getAttributesString($attrs) . " />"; // . $note;
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +135,7 @@ class InputfieldInteger extends Inputfield {
|
|||||||
|
|
||||||
public function getConfigInputfields() {
|
public function getConfigInputfields() {
|
||||||
$inputfields = parent::getConfigInputfields();
|
$inputfields = parent::getConfigInputfields();
|
||||||
|
|
||||||
$f = $this->wire('modules')->get('InputfieldRadios');
|
$f = $this->wire('modules')->get('InputfieldRadios');
|
||||||
$f->attr('name', 'inputType');
|
$f->attr('name', 'inputType');
|
||||||
$f->label = $this->_('Numeric Input Type');
|
$f->label = $this->_('Numeric Input Type');
|
||||||
|
Reference in New Issue
Block a user