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:
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user