1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-24 15:23:11 +02:00

Upgrade FieldtypeText to support importing from multi-language to non-multi-language

This commit is contained in:
Ryan Cramer
2017-08-11 10:39:54 -04:00
parent 9e76a2b770
commit 143e42722d
2 changed files with 20 additions and 1 deletions

View File

@@ -217,7 +217,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
if(!is_array($fieldIDs)) return;
foreach($fieldIDs as $fieldID) {
$field = $this->wire('fields')->get($fieldID);
try {
if($field) try {
// the following forces assets to be loaded
$inputfield = $field->getInputfield($this->page);
if($inputfield) $inputfield->renderReady(null, false);

View File

@@ -224,6 +224,25 @@ class FieldtypeText extends Fieldtype {
}
return $data;
}
/**
* Import value
*
* @param Page $page
* @param Field $field
* @param array|int|object|string $value
* @param array $options
* @return array|string
*
*/
public function ___importValue(Page $page, Field $field, $value, array $options = array()) {
if(is_array($value) && isset($value['default']) && !$this->wire('languages')) {
// multi-language value to non-multi-language site, use only default language
$value = $value['default'];
}
$value = parent::___importValue($page, $field, $value, $options);
return $value;
}
}