Search code examples
yiiclientscript

Yii ClientScript


I would like to know is there a way to check if a coreScript is already registered?

for example the yiiactiveform

Yii::app()->clientScript->registerCoreScript('yiiactiveform');

how to check if this corescript is already registered? thanks


Solution

  • Why do you need to know this? The framework is smart enough to not register the same script twice.

    It seems to me that you can use

    if(Yii::app()->clientScript->getPackageBaseUrl('yiiactiveform') === false) {
      // core script 'yiiactiveform' has not been registered yet
    }
    

    or extend CClientScript and implement a function to answer this, but that might be overkill.