php - Yii2 renderDynamic not working for setting form -


i have form on page using page cache on, need top part of form render dynamically csrf token changes every time, when put code in

<?php $this->renderdynamic('return $form = activeform::begin();'); ?> 

i error call member function field() on non-object on line

<?= $form->field($model, $nbateam['id'])->checkbox(['label' => null, 'data-seed' => $nbateam['seed']]) ?> 

i error in apache error log class 'activeform' not found

i found workaround renderdynamic not seem work yii widgets. used jquery modify value of csrf token after page loaded cache.

$this->registerjs("$(document).ready(function(){     $('input[name=_csrf]').val('".$this->renderdynamic('return yii::$app->request->csrftoken;')."'); });", view::pos_end); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

php - Find a regex to take part of Email -

javascript - Function overwritting -