-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TabularInput not working in bootstrap modal. #58
Comments
@hirenbhut93 Can you provide an example of code to reproduce an issue |
My View Code<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin([
'id' => 'multi-input',
]); ?>
<?= unclead\widgets\TabularInput::widget([
'models' => $models,
'addButtonPosition' => unclead\widgets\MultipleInput::POS_HEADER,
'addButtonOptions' => [
'class' => 'btn btn-success',
'label' => '<i class="glyphicon glyphicon-plus"></i> Add More'
],
'removeButtonOptions' => [
'class' => 'btn btn-danger',
'label' => '<i class="glyphicon glyphicon-remove"></i> Remove'
],
'allowEmptyList' => false,
'attributeOptions' => [
'enableAjaxValidation' => true,
'enableClientValidation' => false,
'validateOnChange' => false,
'validateOnSubmit' => true,
'validateOnBlur' => false,
],
'columns' => [
[
'name' => 'egl_name',
'title' => $models[0]->getAttributeLabel('egl_name'),
'enableError' => true,
],
[
'name' => 'egl_min_marks',
'title' => $models[0]->getAttributeLabel('egl_min_marks'),
'enableError' => true,
],
[
'name' => 'egl_max_marks',
'title' => $models[0]->getAttributeLabel('egl_max_marks'),
'enableError' => true,
],
[
'name' => 'egl_point',
'title' => $models[0]->getAttributeLabel('egl_point'),
'enableError' => true,
],
[
'name' => 'egl_level',
'title' => $models[0]->getAttributeLabel('egl_level'),
'type' => 'radioList',
'enableError' => true,
'items' => $models[0]->getGradeLevelList(),
],
],
]) ?>
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-primary' : 'btn btn-info']) ?>
<?php ActiveForm::end(); ?> My Controller Actionpublic function actionCreate()
{
$esModel = new DemoSingle();
$models = [new DemoMulti()];
if ($esModel->load(Yii::$app->request->post()) && $eglData = Yii::$app->request->post('DemoMulti', [])) {
foreach (array_keys($eglData) as $index) {
$models[$index] = new DemoMulti();
}
if (Model::loadMultiple($models, Yii::$app->request->post()) && Yii::$app->request->isAjax) {
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return \yii\widgets\ActiveForm::validateMultiple($models);
}
if ($esModel->save()) {
foreach ($models as $single) {
// my code
}
}
} elseif(Yii::$app->request->isAjax) {
return $this->renderAjax('create', [
'esModel' => $esModel,
'models' => $models
]);
}
return $this->render('create', [
'esModel' => $esModel,
'models' => $models,
]);
} Note
|
I have tried to reproduce and for me everything works correctly. |
@unclead Your given code is work for Note:
My button code like this<?= Html::a('<span class="glyphicon glyphicon-plus-sign"></span> Create New', ['create'], ['class' => 'btn btn-default link-modal']) ?> My jquery code like thisjQuery(document).on('ready pjax:success', function() {
$('.link-modal').click(function(e) {
e.preventDefault();
$('#my-modal').modal('show').find('.modal-content').load($(this).attr('href'));
});
}); |
I don't know whether i have reproduced this issue correctly or not, but i found the following. When you get TabularInput via ajax you must specify an id for widget
otherwise the widget will get random ID and it can be the same as id of others elements on the page. But after i specified id the widget become to work correct (http://prntscr.com/a8ikyc) |
@unclead thanks |
You are right. There is a bug with validation of this types of input. I found the reason but i need a time to fix it. I created separate issue #64 This issue is solved and i close it. |
I implement
TabularInput
widget in bootstrap modal but is not workingAdd More
button and ajax validation.Please check this issue.The text was updated successfully, but these errors were encountered: