From 2c8cce1d4753751bdd8a33a6c1c583d03b12d25f Mon Sep 17 00:00:00 2001 From: lostkobrakai Date: Wed, 12 May 2021 10:35:44 -0400 Subject: [PATCH] Add PR #77 - Make FieldtypeOptions detect single value usage in markupValue() method --- .../Fieldtype/FieldtypeOptions/FieldtypeOptions.module | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module b/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module index c3224197..37391b86 100644 --- a/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module +++ b/wire/modules/Fieldtype/FieldtypeOptions/FieldtypeOptions.module @@ -224,6 +224,12 @@ class FieldtypeOptions extends FieldtypeMulti implements Module { * */ public function ___markupValue(Page $page, Field $field, $value = null, $property = '') { + $inputfieldClass = $field->get('inputfieldClass'); + if($inputfieldClass && $value instanceof WireArray) { + // render single value rather than list of them when input only accepts 1 selection + $interfaces = wireClassImplements($inputfieldClass); + if(!in_array('InputfieldHasArrayValue', $interfaces)) $value = $value->first(); + } if(empty($property)) $property = 'title'; return parent::___markupValue($page, $field, $value, $property); }