buttonbox icon indicating copy to clipboard operation
buttonbox copied to clipboard

Button Box not showing correct state after being saved within Vizy component

Open tomkiss opened this issue 1 year ago • 0 comments

Describe the bug

I have a buttonbox field saved as a button configuration, and the field is stored within a Vizy component type.

When the entry is saved, the value is stored and correctly outputs in the front-end twig template.

However, when editing the entry again, the UI is not correctly showing the selected button; instead, simply shows the default as being selected.

Steps to reproduce

  1. Create a buttonbox field type with button configuration
  2. Place the field within a vizy component
  3. Save an entry with the component that has the buttonbox field in
  4. Verify that the value is saved but that the edit entry UI is not correctly showing which value has been saved

Having looked at the plugin source code, it seems that the code for this field is incorrectly reporting that the Vizy component "isFresh", when it's not. If I edit line 159 of src/fields/Buttons.php and remove:

// If this is a new entry, look for a default option
if ($this->isFresh($element)) {
  //$value = $this->defaultValue(); // line removed
}

...then the bug no longer occurs.

Craft CMS version

4.2.7

Plugin version

4.1.0

Multi-site?

No

Additional context

No response

tomkiss avatar Oct 14 '22 09:10 tomkiss