我想在yii2中使用克隆值更新表单

时间:2017-05-25 08:50:48

标签: php yii2 yii2-advanced-app yii2-model

在更新中,我使用两个模型的值与克隆字段,在模型变量中,有值但未显示。 此错误正在显示 PHP致命错误 - yii \ base \ ErrorException 在数组

上调用成员函数isAttributeRequired()

我的表单代码:

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use frontend\models\PartyM;
use frontend\models\ProductM;
use frontend\models\Category;  
/**
To add date picker and multiselection from dropdown list 
Date: 03 April 2017
*/
use kartik\date\DatePicker; 
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model frontend\models\SaleorderM */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="saleorder-m-form"> 

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($modelm, 'ac_code')->dropDownList(ArrayHelper::map(PartyM::find()->where('type= :type', ['type' => 'S'])->all(),'ac_code','firmname'),['prompt'=>'Select Firmname'])->label("Firm Name");?>

<div id='main-product-section form-field' class='clonediv'>
<div class="product-section1 test1" id='1'>

<div class="product-area">

<?= $form->field($modeld, 'categoryid[]')->dropDownList(ArrayHelper::map(Category::find()->all(), 'categoryid', 'categoryname'),['prompt'=>'Select....'],['class' => 'your_class', 'id' => 'brandid1'])->label("Brand") ?> 
</div>

<div class="code-area">
<?php 
echo $form->field($modeld, 'productcode[]')->dropDownList(['prompt'=>'Select....'],['id'=>'brandid1-productcode'])->label("Product Code")?>
</div>
<div class="qty-area ">
<?= $form->field($modeld, 'qty[]')->textInput()->label("Quantity"); ?> 
</div>
<div class="btn-area del">          
<a href='javascript:void(0)' class='del_clone' id='del_clone-1' onclick='return delrow(this.id)'; ><span class="glyphicon glyphicon-trash"></span></a>
</div>
</div>
</div>

<div class="form-group">
<div class="btn-area add">      
<a href='javascript:void(0)' class='add_more' id='add_more' >Add More</a>
</div>
</div>
<?= $form->field($modeld, 'ordertype')->textInput()->label("Order Type"); ?>
<?php
// To add date picker 
echo $form->field($modelm, 'orderdate')->widget(DatePicker::classname(), [
'name' => 'Saleorder Date',
'type' => DatePicker::TYPE_COMPONENT_APPEND,
'value' => date('Y-m-d'),
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy-mm-dd'
]
])->label("Saleorder Date"); ?>

<?= $form->field($modelm, 'courier')->textInput(['maxlength' => true])->label("Courier"); ?>

<?= $form->field($modelm, 'couriermode')->textInput(['maxlength' => true])->label("Courier Mode"); ?>

<?= $form->field($modelm, 'ordersource')->textInput(['maxlength' => true])->label("Order Source"); ?>

<?= $form->field($modelm, 'remarks')->textarea(array('rows'=>2,'cols'=>5)) ?>

<div class="form-group">
<?= Html::submitButton($modelm->isNewRecord ? 'Create' : 'Update', ['class' => $modelm->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>

</div>

0 个答案:

没有答案