我在视图中有一个隐藏的输入字段ActiveForm
<?php $form = ActiveForm::begin(); ?>
<input type="file" id="i_file" name="uploadfile" value="" onchange="abc()">
<?= $form->field($model, 'path')->hiddenInput() ?>
<div class="form-group">
<?= Html::submitButton('submit', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
我正在使用 Javascript 设置它的值,如下所示:
<script>
function abc(){
var tmppath = URL.createObjectURL(event.target.files[0]);
$("#taskreports-path").val(tmppath);
alert(document.getElementById("taskreports-path").value);
}
</script>
警报显示该值已成功设置到字段中。现在我想要一些 php 变量中的输入字段的值,例如:
$var path = //<?= $form->field($model, 'path')->hiddenInput() ?> this field's value
如何在 Yii2 中做到这一点?