<?php echo $form->field($model, "report_id", ['template' => '{input}', 'options' => ['tag' => 'span', 'class' => '']])->hiddenInput(); ?> <?php if ($model->operation === 'select') { ?> <?php echo $form->field($model, "col_label")->textInput(); ?> <?php } ?> <?php echo $form->field($model, "operation")->dropDownList(ReportsConditions::getOperationsList()); ?> <?php echo $form->field($model, "attribute_name")->dropDownList(ArrayHelper::map($model->report->availableProps, 'attribute', 'label')); ?> <?php if (isset($model->operation)) { ?> <?php echo $form->field($model, "function")->dropDownList(array_map(function ($v) { return $v::getLabel(); }, ReportsConditions::getFunctionsList($model->operation)), ['prompt' => Yii::t('reportmanager', 'Select...')]); ?>
}], 'function', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) { // <a href="/rep/delete?id=1" title="Удалить" aria-label="Удалить" data-confirm="Вы уверены, что хотите удалить этот элемент?" data-method="post" data-pjax="0"><span class="glyphicon glyphicon-trash"></span></a> return 1 === 1 ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('reportmanager', 'Delete')]) : ''; }]]]]); ?> <?php echo Html::submitButton(Yii::t('reportmanager', 'Save'), ['class' => 'btn btn-primary']); ActiveForm::end(); Pjax::end(); ?> </div> <?php $this->registerJs(' $("#add_condition").click(function(event) { event.preventDefault(); $.pjax.reload({container:"#conditions", type: "POST", push: false, replace: false}); //Reload GridView /* var maxValue = Math.max.apply(Math,$(\'#table_conditions tbody tr\').map(function(){ return this.getAttribute("data-index");})); var number = maxValue + 1; var col1 = ' . json_encode(Html::dropDownList('ReportsConditions[_XXX_][attribute_name]', NULL, ArrayHelper::map($report->availableProps, 'attribute', 'label'), ['class' => 'form-control', 'id' => 'reportsconditions-_XXX_-attribute_name'])) . '; var col2 = ' . json_encode(Html::dropDownList('ReportsConditions[_XXX_][operation]', NULL, ReportsConditions::getOperationsList(), ['class' => 'form-control'])) . '; var html = \'<tr data-index="\' + number + \'">\' + \'<td>\' + col1 + \'</td>\' + \'<td>\' + col2 + \'</td>\' + \'<td></td>\' + \'<td></td>\' + \'</td>\'; $("#table_conditions tbody").append(html.replace(/_XXX_/g,number)); */ }) ');