From 0844bf2e47edd15da0d65fc32057fdeae4b01273 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 20 Dec 2016 06:27:26 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#119 --- wire/core/Inputfield.php | 2 +- .../InputfieldPage/InputfieldPage.module | 1 + .../Inputfield/InputfieldSelect.module | 23 +++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/wire/core/Inputfield.php b/wire/core/Inputfield.php index 3fd18c08..d47ccc9d 100644 --- a/wire/core/Inputfield.php +++ b/wire/core/Inputfield.php @@ -1253,7 +1253,7 @@ abstract class Inputfield extends WireData implements Module { $field = $this->modules->get('InputfieldInteger'); $value = (int) $this->getSetting('columnWidth'); if($value < 10 || $value >= 100) $value = 100; - $field->label = sprintf($this->_("Column Width (%d%%)"), $value); + $field->label = sprintf($this->_('Column width (%d%%)'), $value); $field->icon = 'arrows-h'; $field->attr('id+name', 'columnWidth'); $field->attr('type', 'text'); diff --git a/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module b/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module index 4ac34047..cb5f4499 100644 --- a/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module +++ b/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module @@ -1082,6 +1082,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { } $field->label = $this->_('Custom PHP code'); $field->icon = 'code'; + $field->showIf = 'inputfield!=InputfieldPageAutocomplete|InputfieldPageListSelect|InputfieldPageListSelectMultiple'; $fieldset->append($field); $inputfields->append($fieldset); diff --git a/wire/modules/Inputfield/InputfieldSelect.module b/wire/modules/Inputfield/InputfieldSelect.module index 5cf44d1f..8fdd4457 100644 --- a/wire/modules/Inputfield/InputfieldSelect.module +++ b/wire/modules/Inputfield/InputfieldSelect.module @@ -450,7 +450,7 @@ class InputfieldSelect extends Inputfield { * * @param string $key * @param mixed $value - * @return $this + * @return Inputfield|InputfieldSelect * */ public function set($key, $value) { @@ -469,7 +469,7 @@ class InputfieldSelect extends Inputfield { * * @param array|string $key * @param array|int|string $value - * @return $this + * @return Inputfield|InputfieldSelect * */ public function setAttribute($key, $value) { @@ -528,14 +528,19 @@ class InputfieldSelect extends Inputfield { $inputfields = parent::___getConfigInputfields(); - $f = $this->wire('modules')->get('InputfieldTextarea'); + if($this instanceof InputfieldHasArrayValue) { + $f = $this->wire('modules')->get('InputfieldTextarea'); + $f->description = $this->_('To have pre-selected default value(s), enter the option values (one per line) below.'); + } else { + $f = $this->wire('modules')->get('InputfieldText'); + $f->description = $this->_('To have a pre-selected default value, enter the option value below.'); + } $f->attr('name', 'defaultValue'); - $f->attr('value', $this->defaultValue); - $f->label = $this->_('Default Value'); - $f->description = $this->_('To have pre-selected default value(s), enter the option values (one per line) below. For page selections, this would be the page ID number(s).'); - $f->notes = $this->_('This default value(s) option is available because you checked the "required" box above.'); - $f->showIf = 'required>0'; - $f->collapsed = Inputfield::collapsedBlank; + $f->label = $this->_('Default value'); + $f->attr('value', $this->defaultValue); + $f->description .= ' ' . $this->_('For default page selection, the value would be the page ID number.'); + $f->notes = $this->_('IMPORTANT: The default value is not used unless the field is required (see the “required” checkbox on this screen).'); + $f->collapsed = $this->hasFieldtype === false ? Inputfield::collapsedBlank : Inputfield::collapsedNo; $inputfields->add($f);