nystudio107 / generator-craftplugin

generator-craftplugin is a Yeoman generator for Craft CMS plugins
MIT License
73 stars 30 forks source link

Wrong assets bundle used in widget settings template #23

Closed stefan-h-singer closed 7 years ago

stefan-h-singer commented 7 years ago

In my case, the generated generated: {% do view.registerAssetBundle("wmyl\\wmylforms\\assetbundles\\wmylforms\\WmylFormsAsset") %} when the class actually is: {% do view.registerAssetBundle("wmyl\\wmylforms\\assetbundles\\latestwmylformswidget\\LatestWmylFormsWidgetAsset") %}

khalwat commented 7 years ago

So this is actually "right" -- for the _settings.twig templates, it doesn't create a separate AssetBundle, it just uses your main plugin's AssetBundle.

You can of course change this to be anything you want.

The Widget's _body.twig template, however, does have a custom AssetBundle just for the widget.

stefan-h-singer commented 7 years ago

But the generated AssetsBundle was named after the Widget, not the plugin, which is why I had to change the registerAssetBundle call. The generated code did not work out of the box.

However, it probably only happens if you specify a custom name for the widget.

khalwat commented 7 years ago

The asset bundle named after the widget is for the _body.twig template