Hello Friends,
I have one problem with upload of file with array of file input element of active form, my problem is when i upload one with first input element so, validate all file input elements.
I have attached screen shot for better understanding.
Thanks in Advance,
<?php $form = ActiveForm::begin([
'id' => 'stu-docs-form',
'action' => ['adddocs'],
'options' => ['enctype' => 'multipart/form-data',],
'fieldConfig' => [
'template' => "{label}{input}{error}",
],
]);
for($i=0;$i<count($docs);$i++) :
if(in_array($docs[$i]->doc_category_id, $doc_id))
continue;
else
{
?>
<div class="col-xs-12 col-sm-12 col-lg-12" style="background-color:#f4f4f4; border-bottom:2px solid #ddd;margin-bottom:2%;padding:1%">
<div class="col-xs-12 col-sm-4 col-lg-4">
<?= $form->field($stu_docs, 'stu_docs_category_id_temp[]')->textInput(['maxlength' => 100, 'value' => $docs[$i]->doc_category_name, 'readOnly' => true]) ?>
<?= $form->field($stu_docs, 'stu_docs_category_id[]', ['template' => "{input}"])->hiddenInput(['value' => $docs[$i]->doc_category_id]); ?>
</div>
<div class="col-xs-12 col-sm-4 col-lg-4">
<?= $form->field($stu_docs, 'stu_docs_details[]')->textInput(['maxlength' => 100]) ?>
<?= $form->field($stu_docs, 'stu_docs_stu_master_id', ['template' => "{input}"])->hiddenInput(['value' => $model->stu_master_id]); ?>
</div>
<div class="col-xs-12 col-sm-4 col-lg-4 no-padding">
<div class="col-lg-6 col-sm-6">
<?= $form->field($stu_docs, 'stu_docs_path[]')->fileInput(['data-filename-placement' => "inside"]); ?>
</div>
</div>
</div>
<?php
}
endfor;
?>
<div class="form-group col-xs-12 col-sm-3" style="<?= $st; ?>;margin-top: 10px;">
<?= Html::submitButton('<i class="fa fa-upload"></i> Upload', ['class' => $stu_docs->isNewRecord ? 'btn btn-success btn-block' : 'btn btn-primary btn-block']) ?>
</div>
<?php ActiveForm::end(); ?>