New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP: the JS variable Statamic.fieldtypeDefaults is always empty (easy to fix) #2249

marsvogel opened this Issue Nov 16, 2018 · 1 comment


None yet
2 participants

marsvogel commented Nov 16, 2018

Describe the bug

In control panel the JS variable Statamic.fieldtypeDefaults is always empty due to a missing inherited variable by reference from the parent scope in \Statamic\Http\ViewComposers\FieldtypeJsComposer::fieldtypeJs

Just stumbled upon this, while code diving. In this method there is an array $defaults defined outside the scope of an anonymous function. This array gets its assignments in this anonymous function but is not inherited by reference. Which leads to an always empty array outside the anonymous function.

Affected Line: statamic/core/Http/ViewComposers/FieldtypeJsComposer.php:38


$str = collect($this->repo->fieldtypes()->files())->map(function ($path) {

Should be this

$str = collect($this->repo->fieldtypes()->files())->map(function ($path) use (&$defaults) {

Environment details

  • Statamic Version 2.11.2

This comment has been minimized.


jasonvarga commented Nov 21, 2018

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment