Hi everyone,
i trying to get value from modal popup form using renderAjax. how to get the value when we are in create action?
my action modal
public function actionList(){
$searchModel = new PricelistSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->renderAjax('list', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
modal view
<?php
use yii\helpers\Html;
use kartik\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\PricelistSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
include '../config/exportConfig.php';
$this->title = 'List Harga';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="pricelist-index">
<?php
$gridColumns = [
'id',
'date',
[
'attribute' => 'agen_id',
'value' => 'agen.agen_name'
],
['attribute' => 'price', 'format' => ['decimal', 0]],
'remark_1:ntext',
'remark_2:ntext',
] ?>
<?=
GridView::widget([
'id' => 'kv-grid-pricelist',
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'columns'=>$gridColumns,
'containerOptions'=>['style'=>'overflow: auto'],
'headerRowOptions'=>['class'=>'kartik-sheet-style'],
'filterRowOptions'=>['class'=>'kartik-sheet-style'],
'pjax'=>true, // pjax is set to always true for this demo
// 'export'=>[
// 'fontAwesome'=>true
// ],
// parameters from the demo form
'bordered'=>true,
'striped'=>false,
'condensed'=>true,
'responsive'=>false,
'hover'=>true,
'showPageSummary'=>false,
'panel'=>[
'type'=>GridView::TYPE_PRIMARY,
],
'persistResize'=>false,
'exportConfig'=>$defaultExportConfig,
]);
?>
my action create form
<div class="col-xs-4">
<?= $form->field($model, 'price')->widget(\yii\widgets\MaskedInput::className(),
[
'clientOptions' => [
'alias' => 'numeric',
'groupSeparator' => ',',
'digits' => 0,
'autoGroup' => true,
'removeMaskOnSubmit' => true,
'rightAlign' => false,
]
]) ?>
</div>
<div class="col-xs-8">
<div class="form-group field-poagen-price">
<br>
<?= Html::button('Price List', ['value' => Url::to('../pricelist/list'), 'class' => 'btn btn-primary', 'id' => 'pricelistModalButton']) ?>
<?php
Modal::begin([
'header' => 'List Harga',
'id' => 'modal',
'size' => 'modal-md'
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>
</div>
</div>
and my registered js script
$(function(){
$('#pricelistModalButton').click(function(){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});
});
What should i do?
Thanks before.