Comments (7)
@hirenbhut93 Can you provide an example of code to reproduce an issue
from yii2-multiple-input.
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 Action
public 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
This code without bootstrap modal work perfect
YourMultipleInput
widget is work perfectly in bootstrap modal butTabularInput
is not work.
from yii2-multiple-input.
I have tried to reproduce and for me everything works correctly.
See my gist https://gist.github.com/unclead/bb4edad36ee5767facb7
If you try to use widget in other way please provide the code snippet which can me help to understand how you are using TabularInput
with Modal
Also it can be usefull if you make a screenshot of Console
tab in chrome dev tool. Probably i have some js errors there
from yii2-multiple-input.
@unclead Your given code is work for Add More and Remove button
in Bootstrap
Modal but Ajax validation
not work in my first row. when i added more row at time other row validation successfully.
Note:
I call
Bootstrap
Modal usingload()
method below jquery.
Ajax validation is not work inRadio button
for me with or withoutmodal
.
NoJS Errors
produce in my browserConsole
.
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 this
jQuery(document).on('ready pjax:success', function() {
$('.link-modal').click(function(e) {
e.preventDefault();
$('#my-modal').modal('show').find('.modal-content').load($(this).attr('href'));
});
});
from yii2-multiple-input.
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
<?= unclead\widgets\TabularInput::widget([
'id' => 'some-id
'models' => $models,
otherwise the widget will get random ID and it can be the same as id of others elements on the page.
In my case it was id w0 and the page has already contained Nav widget with the same ID that is why TabularInput has not been initialized in correct way and nothing has worked.
But after i specified id the widget become to work correct (http://prntscr.com/a8ikyc)
from yii2-multiple-input.
@unclead thanks Ajax Validation and Add More Problem resolved
but Ajax validation is not work in Radio button for me with or without modal.
from yii2-multiple-input.
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.
from yii2-multiple-input.
Related Issues (20)
- Cloning doesn't work for nested MultipleInput
- Add manual for each field for custom tabular input? HOT 4
- Embedded does not work correctly HOT 10
- duplicate keys causing strange behavior HOT 2
- Adding new row with DepDrop suddenly not working.
- Is it possible to keep the selected value of a DepDrop when submit returns error? HOT 1
- wrong version hardcoded in composer.json HOT 1
- add button position POS_ROW_BEGIN is shown under the first column HOT 6
- render addons in text fields HOT 2
- Html name attribute HOT 2
- all icon missing HOT 7
- Не работает подсветка ошибок при валидации вновь добавленных полей HOT 1
- The array is converted into an object
- Add button not showing in actionUpdate HOT 1
- Can't handle model update HOT 2
- Yii2 advanced template and Bootstrap 5 HOT 1
- Unable to get the file.
- Иногда не обновляется currentIndex после добавления первой строки HOT 3
- Не работает подсветка ошибок если полей более 9 HOT 1
- DateTimePicker HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-multiple-input.