Inline Javascript / CSP 2.0

Hi!

Is it possible (in easy way ;)) to force Yii2 to stop using inline JS (eg. from yiiActiveForm) and write it to web/assets/ ?

Best wishes,

Chris

For every ActiveForm the code generated depends on your fields. So if you have different forms in your project, that many different asset files.

Complicated… But if you understand how the inline javascript is generated by ActiveForm, how to extend a class and how to publish assets, I think you can do it.

Hi,

Thank you. I’m working on banking application, disabling inline JS is required by eg. OWASP.

There’s some places where JS is generated, not only in ActiveForm. I think the best way will be to rewrite registerJs in View Class and make something similiar to AssetsManager.

Best wishes,

Chris