Hello. how can I validate my TabularForm
VIEW:
<?php $form = ActiveForm::begin([
]); ?>
<?= $form->errorSummary($model); ?>
<?= $form->field($model, 'quizId')->textInput(['placeholder' => 'QuizId'])->label(false)->hiddenInput() ?>
<?= $form->field($model, 'topic')->textInput(['maxlength' => true, 'placeholder' => 'Topic']) ?>
<?= $form->field($model, 'display')->checkbox(['checked' => true]) ?>
<?php
$forms = [
[
'label' => '<i class="glyphicon glyphicon-book"></i> ' . Html::encode('QuizQuestion'),
'content' => $this->render('_formQuizQuestion', [
'row' => \yii\helpers\ArrayHelper::toArray($model->quizQuestions),
]),
],
];
echo kartik\tabs\TabsX::widget([
'items' => $forms,
'position' => kartik\tabs\TabsX::POS_ABOVE,
'encodeLabels' => false,
'pluginOptions' => [
'bordered' => true,
'sideways' => true,
'enableCache' => false,
],
]);
?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
_formQuizQuestion
VIEW:
$dataProvider = new ArrayDataProvider([
‘allModels’ => $row,
‘pagination’ => [
‘pageSize’ => -1
]
]);
echo TabularForm::widget([
‘dataProvider’ => $dataProvider,
‘formName’ => ‘QuizQuestion’,
‘checkboxColumn’ => false,
‘actionColumn’ => false,
‘attributeDefaults’ => [
‘type’ => TabularForm::INPUT_TEXT,
],
‘attributes’ => [
‘quizQuestionId’ => [‘type’ => TabularForm::INPUT_HIDDEN],
‘question’ => [‘type’ => TabularForm::INPUT_TEXT],
‘type’ => [
‘type’ => TabularForm::INPUT_DROPDOWN_LIST,
‘items’ => [NULL=>’’,‘MC’ => ‘MC’, ‘SQ’ => ‘SQ’]
],
‘display’ => [‘type’ => TabularForm::INPUT_CHECKBOX,
‘options’ => [
‘style’ => ‘position : relative; margin-top : -9px’
]
],
‘del’ => [
‘type’ => ‘raw’,
‘label’ => ‘’,
‘value’ => function($model, $key) {
return
Html::hiddenInput(‘Children[’ . $key . ‘][id]’, (!empty($model[‘id’])) ? $model[‘id’] : “”) .
Html::a(’’, ‘#’, [‘title’ => ‘Delete’, ‘onClick’ => ‘delRowQuizQuestion(’ . $key . ‘); return false;’, ‘id’ => ‘quiz-question-del-btn’]);
},
],
],
‘gridSettings’ => [
‘panel’ => [
‘heading’ => false,
‘type’ => GridView::TYPE_DEFAULT,
‘before’ => false,
‘footer’ => false,
‘after’ => Html::button(’’ . ‘Add QuizQuestion’, [‘type’ => ‘button’, ‘class’ => ‘btn btn-success kv-batch-create’, ‘onClick’ => ‘addRowQuizQuestion()’]),
]
]
]);
echo "
?>