Modals And Js

Hi guys.

Suppose I have a modal window with ActiveForm in it.

Content for this modal is loaded via AJAX (partial view), so there’s no html/body tags, thus no ActiveForm’s javascript is rendered.

Is it OK to use


<?php $this->beginPage(); ?>

<?php $this->beginBody(); ?>

<!-- MODAL CONTENT HERE -->

<?php $this->endBody(); ?>

<?php $this->endPage(); ?>

inside partials, or there’s much better way (for example, direct access to registered code block)?

STATUS UPDATE: Now this issue is fixed by new function renderAjax.

i think you can resgister the asset bundle for ther active form in ther parent page and in the partial view you just call the method for activeform plugin

No, because

  1. different forms can be loaded into this modal

  2. client validation is different for every form, so different js code must be registered.

Right now I’m using beginPage/endPage inside my partials, works fine.

Just wondering if there’s a better way.

I mean you just add the validate.form.js and active.form.js in parent page, and in the partial view you just add




<script>

$(function(){

jQuery('#$id').yiiActiveForm($forms->attributes, $fomrs->getClientOptions);

})


<script>



Yes, this is the expected way. We probably will introduce some helper method to simplify this. Could you create a github ticket about this? Thanks.