outl1ne / nova-page-manager

Static page and region manager for Laravel Nova - designed for headless CMS's.
MIT License
178 stars 38 forks source link

Configuration caching error #81

Closed shahruslan closed 3 years ago

shahruslan commented 3 years ago

If in the nova-page-manager.php file, in the seo_fields key, specify an array of fields of the Text type:

    'seo_fields' => [
        Text::make('SEO Title', 'title_seo'),
        Textarea::make('SEO Description', 'description_seo'),
        Text::make('SEO Keywords', 'keywords_seo'),
    ],

when caching the configuration(php artisan optimize), we get an error: Method Laravel\\Nova\\Fields\\Text :: __ set_state does not exist. The Callable array is working fine.

Tarpsvo commented 3 years ago

Hmm, I think you might need to use a callable for that. Define a global function (or a static class function) and use that as the config value instead. Ie:

function get_pagemanager_seo_fields() {
  return [
    // ...
  ];
}

// ...

'seo_fields' => 'get_pagemanager_seo_fields',
shahruslan commented 3 years ago

Yes, that's exactly what I did. I think this should be written in the documentation(readme). So that other people don't have problems.