我在yii2视图页面中有bootstarp标签每个标签都有不同模型的活动表单。客户端在所有表单上都运行良好。但表格上的表格提交无效。只有一种形式工作正常。其他人没有提交表格。
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a class="active" data-toggle="tab" data-target="#customers"><span>Customer</span></a></li>
<li><a data-toggle="tab" data-target="#drivers"><span>Drivers</span></a></li>
<li><a data-toggle="tab" data-target="#agents"><span>Agents</span></a></li>
</ul>
<div class="tab-content">
<div id="customers" class="tab-pane" style="display:none">
<?php $form = ActiveForm::begin(['action' => Url::to(['/account/customer_transaction'])]); ?>
<?= $form->field($transaction, 'customer_selection_type')->radioList([1 => Yii::t('backend', 'ALL_CUSTOMERS'), 2 => Yii::t('backend', 'SELECT_CUSTOMER')]) ?>
<?= $form->field($transaction, 'customer')->dropDownList(ArrayHelper::map($customers, 'u_user_id', 'u_full_name'), ['class' => 'selectpicker', 'multiple' => true]) ?>
<?= $form->field($transaction, 'transaction_type')->radioList([1 => Yii::t('backend', 'CREDIT'), 2 => Yii::t('backend', 'DEBIT')]) ?>
<?= $form->field($transaction, 'transaction_amount')->textInput() ?>
<?= $form->field($transaction, 'remarks')->textArea(['rows' => 4]) ?>
<?= Html::submitButton(Yii::t('backend', 'SUBMIT'), ['class' => 'btn btn-success'])?>
<?php ActiveForm::end(); ?>
<h2>Transaction</h2>
<div class="transactiondetail-index">
<?php Pjax::begin(); ?> <?= GridView::widget([
'dataProvider' => $customerDataProvider,
'filterModel' => $customerSearchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'td_created_datetime',
'format' => ['date', 'dd-M-Y, HH:i:ss'],
'filter' => false,
],
[
'attribute' => 'user.u_full_name',
'filter' => Html::activeDropDownList($customerSearchModel, 'td_user_id', ArrayHelper::map($customers, 'u_user_id', 'u_full_name'), ['prompt' => Yii::t('backend', 'SELECT_CUSTOMER')])
],
[
'attribute' => 'td_transaction_type',
'value' => function($model){
if($model->td_transaction_type == 1)
return Yii::t('backend', 'REFERRAL');
else if($model->td_transaction_type == 2)
return Yii::t('backend', 'PROMO');
else if($model->td_transaction_type == 3)
return Yii::t('backend', 'Gateway');
else if($model->td_transaction_type == 4)
return Yii::t('backend', 'TRIP');
else if($model->td_transaction_type == 5)
return Yii::t('backend', 'CREDIT');
else if($model->td_transaction_type == 6)
return Yii::t('backend', 'DEBIT');
},
'filter' => Html::activeDropDownList($customerSearchModel, 'td_transaction_type', [1 => Yii::t('backend', 'REFERRAL'), 2 => Yii::t('backend', 'PROMO'), 5 => Yii::t('backend', 'CREDIT'), 6 => Yii::t('backend', 'DEBIT')], ['prompt' => Yii::t('backend', 'SELECT_TRANSACTION_TYPE')])
],
'td_amount',
'td_previous_wallet_balance',
'td_current_wallet_balance',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view}',
'buttons' => [
'view' => function($url, $model, $id){
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['account/view_customer_transaction', 'id' => $model->td_user_id] , ['target' => '_blank']);
}
],
],
],
]); ?>
<?php Pjax::end(); ?>
</div>
</div>
<div id="drivers" class="tab-pane" >
<div class="driver_form">
<?php $driverForm = ActiveForm::begin(['action' => Url::to(['/account/driver_transaction']), 'options' => ['id' => 'driver_form']]); ?>
<?= $driverForm->field($driverModel, 'country')->dropDownList(ArrayHelper::map($countries, 'co_id', 'co_name'), ['prompt' => Yii::t('backend', 'SELECT_COUNTRY')]) ?>
<?= $driverForm->field($driverModel, 'city')->dropDownList([], ['prompt' => Yii::t('backend', 'SELECT_CITY')]) ?>
<?= $driverForm->field($driverModel, 'driver_selection_type')->radioList([1 => Yii::t('backend', 'ALL_DRIVERS'), 2 => Yii::t('backend', 'SELECT_DRIVER')]) ?>
<?= $driverForm->field($driverModel, 'driver_id')->dropDownList([], ['class' => 'selectpicker', 'multiple' => true]) ?>
<?= $driverForm->field($driverModel, 'transaction_type')->radioList([1 => Yii::t('backend', 'CREDIT'), 2 => Yii::t('backend', 'DEBIT')]) ?>
<?= $driverForm->field($driverModel, 'transaction_amount')->textInput() ?>
<?= $driverForm->field($driverModel, 'remarks')->textArea(['rows' => 4]) ?>
<?= Html::submitButton(Yii::t('backend', 'SUBMIT'), ['class' => 'btn btn-success'])?>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
如果有人知道,请帮助我
答案 0 :(得分:0)
表单需要唯一的ID。试试这样:
<?php
$form = ActiveForm::begin([
'id' => 'id1'
'action' => Url::to(['/account/customer_transaction'
])]);
?>
答案 1 :(得分:0)
在控制器
中将enableCsrfValidation设置为false <div align="right" class"all_categories_list" style="display:inline-block;width:50%;">
<form>
<select class="select" id="option" name="option" onChange="window.document.location.href=this.options[this.selectedIndex].value;" value="GO" style="width: 25%;">
<option value="*">All Categories</option>
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?><!-----------Level 1 ----->
<?php foreach($_categories as $_category): ?>
<option value="<?php echo $_helper->getCategoryUrl($_category) ?>"><?php echo $_category->getName() ?></option>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories()?>
<?php if (count($_subcategories) > 0):?><!-----------Level 2 ----->
<?php foreach($_subcategories as $_subcategory):?>
<option value="<?php echo $_helper->getCategoryUrl($_subcategory)?>"><?php echo $_subcategory->getName() ?></option>
<?php $_subcategory = Mage::getModel('catalog/category')->load($_subcategory->getId()) ?>
<?php $_subcategoriesss = $_subcategory->getChildrenCategories()?>
<?php if (count($_subcategoriesss) > 0):?><!-----------Level 3 ----->
<?php foreach($_subcategoriesss as $_subcategoryy):?>
<option value="<?php echo $_helper->getCategoryUrl($_subcategoryy)?>"><?php echo $_subcategoryy->getName() ?></option>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</select>
</form>
</div>
<!------------------------All categories and Subcategories level 3 in dropdown ---------------------------->