statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.94k stars 523 forks source link

Namespace for fieldsets from addons not compatible with Fields addValues #8427

Closed NicoRox closed 1 year ago

NicoRox commented 1 year ago

Bug description

I created a addon containing fieldsets. for this example there is a single text field the handle: text-addon::text_component

when I save a entry the data includes this value as follows:

[
  'text-addon::text_component' => 'The value',
  ...
]

In Statamic\Fields\Fields addValues(array $values) the value is extracted from the array using Arr::get since Arr::get uses either . or :: notation for targeting children the code looks for the value as if it should be passed as follows:

[
  'text-addon' => [
    'text_component' => 'The value'
  ],
  ...
]

How to reproduce

Create a statamic addon. Add a fieldset. Use this fieldset inside a blueprint Fill and save the entry

result: Entry is saved exept for the field from the addon

Logs

No response

Environment

Environment
Application Name: Laravel
Laravel Version: 10.14.1
PHP Version: 8.2.7
Composer Version: 2.3.3
Environment: local
Debug Mode: ENABLED
URL: base-statamic-template.test/
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: null
Cache: statamic
Database: mysql
Logs: stack / single
Mail: mailgun
Queue: sync
Session: file

Statamic
Addons: 5
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.9.2 PRO

Statamic Addons
aerni/font-awesome: 2.0.0
roxdigital/statamic-pagebuilder: dev-master
roxdigital/statamic-pagebuilder-examples: dev-feature/package-test

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

None

Additional details

No response

jasonvarga commented 1 year ago

The namespace should not be in the handle. The namespace is only used to resolve the field.

Your entry data should end up like this:

[
-  'text-addon::text_component' => 'The value',
+  'text_component' => 'The value',
  ...
]