1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 08:17:12 +02:00

Some fixes to InputfieldSelector parent.subfield properties, plus fix issue where datetime field didn't always recognize when the date picker should include a time picker as well.

This commit is contained in:
Ryan Cramer
2017-03-19 07:07:52 -04:00
parent 1f23b54f45
commit a410bf8236

View File

@@ -1103,7 +1103,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
$inputfield = null; $inputfield = null;
if(strpos($fieldName, '.') !== false) list($fieldName, $subfield) = explode('.', $fieldName); if(strpos($fieldName, '.') !== false) list($fieldName, $subfield) = explode('.', $fieldName);
if(isset($this->systemFields[$fieldName])) { if(isset($this->systemFields[$fieldName]) && !$subfield) {
// system field // system field
$info = $this->systemFields[$fieldName]; $info = $this->systemFields[$fieldName];
if($fieldName == 'parent' && $this->initTemplate) { if($fieldName == 'parent' && $this->initTemplate) {
@@ -1127,7 +1127,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
} }
} else if(isset($this->modifierFields[$fieldName])) { } else if(isset($this->modifierFields[$fieldName])) {
// modified field // modifier field
$info = $this->modifierFields[$fieldName]; $info = $this->modifierFields[$fieldName];
$type = $info['input']; $type = $info['input'];
if(isset($info['options'])) $options = $info['options']; if(isset($info['options'])) $options = $info['options'];
@@ -1139,14 +1139,20 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
} else if($type == 'selector') { } else if($type == 'selector') {
// selector field: do nothing here but skip it, and respond to it further down // selector field: do nothing here but skip it, and respond to it further down
} else if($field = $this->wire('fields')->get($fieldName)) { } else if(($fieldName == 'parent' && $subfield) || $field = $this->wire('fields')->get($fieldName)) {
/** @var Field $field */ /** @var Field $field */
// custom field // custom field or parent with subfield
$selectorInfo = $this->getSelectorInfo($field); $selectorInfo = $this->getSelectorInfo($field);
if(count($selectorInfo)) { if(count($selectorInfo) || $fieldName == 'parent') {
// information available for custom field // information available for custom field or parent
if($subfield && isset($selectorInfo['subfields'][$subfield])) $selectorInfo = $selectorInfo['subfields'][$subfield]; if($fieldName == 'parent') {
// if parent, there is a subfield, and $field becomes the subfield
$selectorInfo = $this->getSelectorInfo($subfield);
$field = $this->wire('fields')->get($subfield);
} else if($subfield && isset($selectorInfo['subfields'][$subfield])) {
$selectorInfo = $selectorInfo['subfields'][$subfield];
}
$type = $selectorInfo['input']; $type = $selectorInfo['input'];
if($type == 'page') { if($type == 'page') {
@@ -1300,7 +1306,9 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
} else if($type == 'datetime' || $type == 'date') { } else if($type == 'datetime' || $type == 'date') {
// render date/datetime input // render date/datetime input
$out .= $this->renderDateInput($inputName, $selectedValue, $type == 'datetime'); $useTime = $type == 'datetime';
if(!$useTime && $field && $field->get('timeInputFormat')) $useTime = true;
$out .= $this->renderDateInput($inputName, $selectedValue, $useTime);
} else { } else {
// render other input that uses an <input type='text'> whether text, number or selector // render other input that uses an <input type='text'> whether text, number or selector