0

Now I am working with one old system Which were developed with using YII 1 framework.

Yii1 form using some jquery code for form validation and put this code at the end before </body> tag.

I need to make YII1 form to put its validation code a bit above because at the end (before </body> tag) I have my js code.

In Yii2 It is easy to make by using some anchor like this

$this->endBody()

Is There any Way in Yii1 to set up place in layout to put JS code into that place ?

Thanks in advance

Eugene S
  • 161
  • 1
  • 7
  • Why are you trying to switch them? – SiZE Jul 17 '17 at 12:09
  • SiZE ! your question is not clear for me. What do you mean ? concerning my problem I have some JS code before closing "body" tag and yii1 put its "JS form validation" code after my JS code before closing "body" as a result I have some js conflict. I need my JS code will be last and all yii1 js code go before mine. In Yii2 There is $this->endBody() Which is replaced with yii2 js code and developer had possibility to put it into necessary place – Eugene S Jul 18 '17 at 12:38
  • Eugene S, there is no easy solutuion to set js order. But the code should not depend on the location. – SiZE Jul 19 '17 at 07:28
  • Your question is quite hard to understand, but.. in both Yii1 and Yii2 the best/right way to handle javascript is to place it using the methods available for registering javascript/css blocks or js/css files. In Yii1 check `Yii::app()->clientScript->registerScript` and in Yii2 `$this->registerJs` (from view). For more details please search inside Yii API documentations for both 1 and 2. – Alexandru Trandafir Catalin Jul 19 '17 at 23:45

1 Answers1

0

You just add your js file like this in content section or in your html form:

<script src="<?=Yii::app()->theme->baseUrl; ?>/js/bootstrap.min.js"></script>