diff --git a/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue b/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue index f991d0ece2..ff826d51fb 100644 --- a/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue +++ b/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue @@ -7,10 +7,10 @@ ref="button" type="button" :name="name" - @click="updateSelectedOption($event.target.value)" + @click="updateSelectedOption(option.value)" :value="option.value" :disabled="isReadOnly" - :class="{'active': value === option.value}" + :class="{'active': value == option.value}" v-text="option.label || option.value" /> diff --git a/tests/Fieldtypes/HasSelectOptionsTests.php b/tests/Fieldtypes/HasSelectOptionsTests.php index 16719bf2cd..849209c6f1 100644 --- a/tests/Fieldtypes/HasSelectOptionsTests.php +++ b/tests/Fieldtypes/HasSelectOptionsTests.php @@ -14,26 +14,30 @@ public function it_preloads_options($options, $expected) $field = $this->field(['options' => $options]); $this->assertArrayHasKey('options', $preloaded = $field->preload()); - $this->assertEquals($expected, $preloaded['options']); + $this->assertSame($expected, $preloaded['options']); } public static function optionsProvider() { return [ 'list' => [ - ['one', 'two', 'three'], + ['one', 'two', 'three', 50, '100'], [ ['value' => 'one', 'label' => 'one'], ['value' => 'two', 'label' => 'two'], ['value' => 'three', 'label' => 'three'], + ['value' => 50, 'label' => 50], + ['value' => '100', 'label' => '100'], ], ], 'associative' => [ - ['one' => 'One', 'two' => 'Two', 'three' => 'Three'], + ['one' => 'One', 'two' => 'Two', 'three' => 'Three', 50 => '50', '100' => 100], [ ['value' => 'one', 'label' => 'One'], ['value' => 'two', 'label' => 'Two'], ['value' => 'three', 'label' => 'Three'], + ['value' => 50, 'label' => '50'], + ['value' => 100, 'label' => 100], ], ], 'multidimensional' => [ @@ -41,11 +45,15 @@ public static function optionsProvider() ['key' => 'one', 'value' => 'One'], ['key' => 'two', 'value' => 'Two'], ['key' => 'three', 'value' => 'Three'], + ['key' => 50, 'value' => 50], + ['key' => '100', 'value' => 100], ], [ ['value' => 'one', 'label' => 'One'], ['value' => 'two', 'label' => 'Two'], ['value' => 'three', 'label' => 'Three'], + ['value' => 50, 'label' => 50], + ['value' => '100', 'label' => 100], ], ], ];