Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Yii2新闻未在更新中显示_Javascript_Php_Jquery_Yii2 - Fatal编程技术网

Javascript Yii2新闻未在更新中显示

Javascript Yii2新闻未在更新中显示,javascript,php,jquery,yii2,Javascript,Php,Jquery,Yii2,我目前在yii2中尝试创建的新闻模块有问题 我有多个与动物产品或植物产品相关的领域。不属于动物的物品将不会显示,反之亦然 现在它在create中运行良好,但在update中却没有显示 newsscript.js $(document).ready(function () { function cleardrop() { $('#newscommodity').html("<option value=''>------- Select --------<

我目前在yii2中尝试创建的新闻模块有问题

我有多个与动物产品或植物产品相关的领域。不属于动物的物品将不会显示,反之亦然

现在它在create中运行良好,但在update中却没有显示

newsscript.js

$(document).ready(function () {
    function cleardrop() {
        $('#newscommodity').html("<option value=''>------- Select --------</option>");                                   
        $('#newsgroups').html("<option value=''>------- Select --------</option>");                                     
        $('#newsorigin').html("<option value=''>------- Select --------</option>");                                          
        $('#newsmanufacture').html("<option value=''>------- Select --------</option>");
        $('#newsintendeduse').html("<option value=''>------- Select --------</option>"); 
        $('#newsfinality').html("<option value=''>------- Select --------</option>");
        $('#newsspecies').html("<option value=''>------- Select --------</option>"); 
    }
    var dept= $('#newsdepartment').val();
    if(dept=='Animal Health'){      
        $("#newsimportcategory").html(
            ["<option value=''>------- Select --------</option>",
            "<option value='Animal and Animal Products'>Animal and Animal Products</option>",
            "<option value='Animal Feed, Biologics and Veterianry Drugs'>Animal Feed, Biologics and Veterianry Drugs</option>"
        ]);

        $('#newsimportcategory').change(function () {
            var impcat= $(this).val();
            if(impcat=='Animal and Animal Products'){                    
                $('#newscategorylabel').removeClass("hide");                   
                $('#newscommoditylabel').removeClass("hide");                                                                        
                $('#newsspecieslabel').removeClass("hide");                                                        
                $('#newsoriginlabel').removeClass("hide");                                                                                   
                $('#newsfinalitylabel').removeClass("hide");                                              
                $('#newsmanufacturelabel').addClass("hide");                                           
                $('#newsgroupslabel').addClass("hide");                                  
                $('#newsintendeduselabel').addClass("hide");
                $.post("/import-conditions/admin/animal/listsimptcat",function(data) {
                    $( "select#newscategory").html(data)                                             
                });
                $('#newscategory').change(function () {
                    cleardrop();
                    $.post("/import-conditions/animal/listscommodity?name=" +$(this).val(),function(data) {
                        $("select#newscommodity").html(data)                                 
                    })                           
                }); 
                $('#newscommodity').change(function () {
                $.post("/import-conditions/animal/listsspecies?name=" +$(this).val(),function(data) {
                    $("select#newsspecies").html(data)                                     
                })      
                $.post("/import-conditions/animal/listsorigin?name=" +$(this).val(),function(data) {
                    $("select#newsorigin").html(data)                                     
                }) 
                $.post("/import-conditions/animal/listsfinality?name=" +$(this).val(),function(data) {
                    $("select#newsfinality").html(data)                                     
                });
            });
            $('#newsorigin').change(function () {
                $.post("/import-conditions/animal/listsfinalitysinglesearch?name=" +$(this).val(),function(data) {
                    $("select#newsfinality").html(data)                                   
                }) ;
            });
        } else if(impcat=='Animal Feed, Biologics and Veterianry Drugs'){                           
            $('#newscategorylabel').removeClass("hide");                                                   
            $('#newscommoditylabel').removeClass("hide");                                                                            
            $('#newsgroupslabel').removeClass("hide");                                                                         
            $('#newsoriginlabel').removeClass("hide");                                                                                       
            $('#newsmanufacturelabel').removeClass("hide");
            $('#newsintendeduselabel').addClass("hide");                                        
            $('#newsfinalitylabel').addClass("hide");
            $('#newsspecieslabel').addClass("hide"); 
            cleardrop();
            $.post("/import-conditions/admin/vetdrugsbiologicsfeed/listsimptcat",function(data) {
                $( "select#newscategory").html(data)                                           
            });
            $('#newscategory').change(function () {
                        cleardrop();
                    $.post("/import-conditions/vetdrugsbiologicsfeed/listscommodity?name=" +$(this).val(),function(data)
                       {
                           $( "select#newscommodity").html(data)

                       }) ;
                });

                     $('#newscommodity').change(function () {
                    $.post("/import-conditions/vetdrugsbiologicsfeed/listsgroups?name=" +$(this).val(),function(data)
                    {
                        $( "select#newsgroups").html(data)

                    })      


                $.post("/import-conditions/vetdrugsbiologicsfeed/listsorigin?name=" +$(this).val(),function(data)
                    {
                        $( "select#newsorigin").html(data)

                    }) 

                     $.post("/import-conditions/vetdrugsbiologicsfeed/listsmanufacture?name=" +$(this).val(),function(data)
                    {
                        $( "select#newsmanufacture").html(data)

                    }) ;
                 });

        }
        else if(impcat==''){

                                      $('#newscategorylabel').addClass("hide");                                  
                                       $('#newscommoditylabel').addClass("hide");                                    
                                         $('#newsgroupslabel').addClass("hide");                                        
                                           $('#newsoriginlabel').addClass("hide");                                           
                                             $('#newsmanufacturelabel').addClass("hide");
                                               $('#newsintendeduselabel').addClass("hide"); 
                                                $('#newsfinalitylabel').addClass("hide");
                                                 $('#newsspecieslabel').addClass("hide"); 
                                                    cleardrop();
        }   

     });

    }
    else if(dept=='Plant Health')
    { 
        $("#newsimportcategory").html(
        ["<option value=''>------- Select --------</option>",
        "<option value='Beneficial Organisms'>Beneficial Organisms</option>",
        "<option value='Plant and Plant Products'>Plant and Plant Products</option>"
        ]); 
         $('#newsimportcategory').change(function () {
         var impcat= $(this).val();

        if(impcat=='Beneficial Organisms'){

                                     $('#newscategorylabel').removeClass("hide");
                                      $('#newsspecieslabel').removeClass("hide");
                                       $('#newsoriginlabel').removeClass("hide");
                                        $('#newscommoditylabel').addClass("hide");                                  
                                         $('#newsfinalitylabel').addClass("hide");
                                          $('#newsmanufacturelabel').addClass("hide");
                                           $('#newsgroupslabel').addClass("hide");
                                            $('#newsintendeduselabel').addClass("hide");

                                        cleardrop();
                $.post("/import-conditions/admin/beneficialorganisms/listsimptcat",function(data)
                      {
                          $( "select#newscategory").html(data)


                      });

                $('#newscategory').change(function () {
                    cleardrop();
                    $.post("/import-conditions/beneficialorganisms/listsspecies?name=" +$(this).val(),function(data)
                          {
                              $( "select#newsspecies").html(data)

                          })  
                          $.post("/import-conditions/beneficialorganisms/listsorigin?name=" +$(this).val(),function(data)
                          {
                              $( "select#newsorigin").html(data)

                          }) 

                });



        }
        else if(impcat=='Plant and Plant Products'){

                                      $('#newscategorylabel').removeClass("hide");                                   
                                       $('#newscommoditylabel').removeClass("hide");
                                        $('#newsspecieslabel').removeClass("hide");
                                         $('#newsintendeduselabel').removeClass("hide");                                                                        
                                           $('#newsoriginlabel').removeClass("hide");                                            
                                             $('#newsmanufacturelabel').addClass("hide");
                                               $('#newsfinalitylabel').addClass("hide");
                                                 $('#newsgroupslabel').addClass("hide");

                                                cleardrop();

                 $.post("/import-conditions/admin/plants/listsimptcat",function(data)
                      {
                          $( "select#newscategory").html(data)


                      });

                      $('#newscategory').change(function () {
                        cleardrop();
                    $.post("/import-conditions/plants/listscommodity?name=" +$(this).val(),function(data)
                          {
                              $( "select#newscommodity").html(data)

                          })                           

                        });     

                       $('#newscommodity').change(function () {

                         $.post("/import-conditions/plants/listsspecies?name=" +$(this).val(),function(data)
                           {
                               $( "select#newsspecies").html(data)

                           })      

                            $.post("/import-conditions/plants/listsintendeduse?name=" +$(this).val(),function(data)
                           {
                               $( "select#newsintendeduse").html(data)

                          }) 

                      $.post("/import-conditions/plants/listsorigin?name=" +$(this).val(),function(data)
                           {
                               $( "select#newsorigin").html(data)

                           }) ; 
                           });      

                           $('#newsorigin').change(function () {
                            $.post("/import-conditions/plants/listsfinalitysinglesearch?name=" +$(this).val(),function(data)
                                                                {
                                                                    $( "select#newsorigin").html(data)

                                                                });
                           });               


        }
        else if(impcat==''){

                                      $('#newscategorylabel').addClass("hide");                                  
                                       $('#newscommoditylabel').addClass("hide");                                    
                                         $('#newsgroupslabel').addClass("hide");                                        
                                           $('#newsoriginlabel').addClass("hide");                                           
                                             $('#newsmanufacturelabel').addClass("hide");
                                               $('#newsintendeduselabel').addClass("hide"); 
                                                $('#newsfinalitylabel').addClass("hide");
                                                 $('#newsspecieslabel').addClass("hide"); 

                                     cleardrop();

        }   

     });


    }
     else if(dept=='Food Safety')
    { 
        $("#newsimportcategory").html(
        ["<option value=''>------- Select --------</option>",
        "<option value='Process Food Products'>Process Food Products</option>"
        ]); 
             $('#newsimportcategory').change(function () {
             var impcat= $(this).val();             
           $.post("/import-conditions/admin/processfood/listsimptcat",function(data)
              {
                  $( "select#newscategory").html(data)


              });

        if(impcat=='Process Food Products'){

                                     $('#newscategorylabel').removeClass("hide");
                                     $('#newscommoditylabel').removeClass("hide");
                                      $('#newsmanufacturelabel').removeClass("hide");                                    
                                       $('#newsoriginlabel').removeClass("hide");
                                         $('#newsspecieslabel').addClass("hide");                                   
                                         $('#newsfinalitylabel').addClass("hide");                                       
                                           $('#newsgroupslabel').addClass("hide");
                                            $('#newsintendeduselabel').addClass("hide");


                                             $('#newscategory').change(function () {
                                                cleardrop();
                                                $.post("/import-conditions/processfood/listscommodity?name=" + $(this).val(),function(data)
                                                {
                                                    $('#newscommodity').html("<option value=''>------- Select --------</option>");
                                                     $('#newsmanufacture').html("<option value=''>------- Select --------</option>");
                                                      $('#newsorigin').html("<option value=''>------- Select --------</option>");

                                                    $( "select#newscommodity").html(data); 

                                                });
                                            });

                                             $('#newscommodity').change(function () {

                                                 $.post("/import-conditions/processfood/listsmanufacture?name=" +$(this).val(),function(data)
                                                                {
                                                                    $( "select#newsmanufacture").html(data)

                                                                });   
                                                            $.post("/import-conditions/processfood/listsorigin?name=" +$(this).val(),function(data)
                                                                {
                                                                    $( "select#newsorigin").html(data)

                                                                }); 

                                             });

        }
        else if(impcat==''){

                                      $('#newscategorylabel').addClass("hide");                                  
                                       $('#newscommoditylabel').addClass("hide");                                    
                                         $('#newsgroupslabel').addClass("hide");                                        
                                           $('#newsoriginlabel').addClass("hide");                                           
                                             $('#newsmanufacturelabel').addClass("hide");
                                               $('#newsintendeduselabel').addClass("hide"); 
                                                $('#newsfinalitylabel').addClass("hide");
                                                 $('#newsspecieslabel').addClass("hide"); 

                                     cleardrop();

        }      


    });

}

 });
$(文档).ready(函数(){
函数cleardrop(){
$('#newscommodity').html(“----选择----”;
$(“#新闻组”).html(“----选择----”;
$('#newsorigin').html(“----选择----”;
$('#newsmanufacture').html(“----选择----”;
$('#newstendeduce').html(“----选择----”;
$('#newsfinality').html(“----选择----”;
$(“#新闻物种”).html(“----选择----”;
}
var dept=$(“#新闻部”).val();
如果(部门==‘动物健康’{
$(“#newsimportcategory”).html(
[“----选择----”,
“动物和动物产品”,
动物饲料、生物制剂和退伍军人药物
]);
$('#newsimportcategory')。更改(函数(){
var impcat=$(this.val();
如果(impcat=='动物和动物产品'){
$(“#newscategorylabel”).removeClass(“隐藏”);
$(“#newscommoditylabel”).removeClass(“隐藏”);
$(“#newsspecieslabel”).removeClass(“隐藏”);
$(“#newsoriginlabel”).removeClass(“隐藏”);
$('newsfinalitylabel')。删除类(“隐藏”);
$('newsmanufacturelabel').addClass(“隐藏”);
$('newsgroupslabel').addClass(“隐藏”);
$('#NewsIntendedUserLabel').addClass(“隐藏”);
$.post(“/import conditions/admin/animal/listsimptcat”,函数(数据){
$(“选择#新闻类别”).html(数据)
});
$('#newscategory')。更改(函数(){
cleardrop();
$.post(“/import conditions/animal/listscommodity?name=“+$(this).val(),函数(数据)){
$(“选择#新闻商品”).html(数据)
})                           
}); 
$('#newscommodity')。更改(函数(){
$.post(“/import conditions/animal/listsspecies?name=“+$(this).val(),函数(数据)){
$(“选择#新闻物种”).html(数据)
})      
$.post(“/import conditions/animal/listsorigin?name=“+$(this).val(),函数(数据)){
$(“选择#新闻来源”).html(数据)
}) 
$.post(“/import conditions/animal/listsfinality?name=“+$(this).val(),函数(数据)){
$(“选择#新闻最终性”).html(数据)
});
});
$('#newsorigin')。更改(函数(){
$.post(“/import conditions/animal/listsfinalitysinglesearch?name=“+$(this).val(),函数(数据){
$(“选择#新闻最终性”).html(数据)
}) ;
});
}否则如果(impcat==‘动物饲料、生物制剂和退伍军人药物’{
$(“#newscategorylabel”).removeClass(“隐藏”);
$(“#newscommoditylabel”).removeClass(“隐藏”);
$(“#新闻组标签”).removeClass(“隐藏”);
$(“#newsoriginlabel”).removeClass(“隐藏”);
$('newsmanufacturelabel')。删除类(“隐藏”);
$('#NewsIntendedUserLabel').addClass(“隐藏”);
$('newsfinalitylabel').addClass(“隐藏”);
$('#newsspecieslabel').addClass(“隐藏”);
cleardrop();
$.post(“/import conditions/admin/vetdrugsbiologicsfeed/listsimptcat”,函数(数据){
$(“选择#新闻类别”).html(数据)
});
$('#newscategory')。更改(函数(){
cleardrop();
$.post(“/import conditions/vetdrugsbiologicsfeed/listscommodity?name=“+$(this).val(),函数(数据)
{
$(“选择#新闻商品”).html(数据)
}) ;
});
$('#newscommodity')。更改(函数(){
$.post(“/import conditions/vetdrugsbiologicsfeed/listsgroups?name=“+$(this).val(),函数(数据)
{
$(“选择#新闻组”).html(数据)
})      
$.post(“/import conditions/vetdrugsbiologicsfeed/listsorigin?name=“+$(this).val(),函数(数据)
{
$(“选择#新闻来源”).html(数据)
}) 
$.post(“/import conditions/vetdrugsbiologicsfeed/listsmanufacture?name=“+$(this).val(),函数(数据)
{
$(“选择#新闻制作
    <?php

            use yii\helpers\Html;
            use yii\widgets\ActiveForm;
            use yii\helpers\ArrayHelper;

            /* @var $this yii\web\View */
            /* @var $model backend\models\News */
            /* @var $form yii\widgets\ActiveForm */
            ?>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js" ></script>
            <div class="news-form">

            <?php $form = ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data']]); ?>

            <div id="pagecontent">
                <h1 align="center">
                    Add New News Form
                </h1>
                <br />
 <table width="90%" border="0" cellspacing="0" cellpadding="8">
                    <tr>
 <td width="30%" align="Right"><h2><strong>News Heading: </strong></h2></td>
 <td width="70%"><label>
  <?= $form->field($model, 'headline')->textInput(['style' => 'width: 900px'])->label(false) ?>
  </label></td>
</tr>
 <tr>
<td align="right"><h2><strong>Content: </strong></h2></td>
                        <td><label>
                             <?= $form->field($model, 'story')->textarea(['rows' => 6,'style' => 'width: 900px; height: 380px;'])->label(false) ?>


 </label></td>
</tr>
<tr>
 <td width="30%" align="Right"><h2><strong>Department: </strong></h2></td>
<td width="70%"><label>
 <?= $form->field($model, 'department')->textInput(['style' => 'width: 400px','readonly'=>true,'value'=>Yii::$app->user->identity->department,'id'=>'newsdepartment'])->label(false) ?>
   </label></td>
 </tr>
 <tr>
<td width="30%" align="Right"><h2><strong>Import Category: </strong></h2></td>
 <td width="70%"><label>
  <?= $form->field($model, 'importcategory')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
  [   
'id'=>'newsimportcategory',                                                             
'style' => 'width:400px',
  ])->label(false);?>
 </label></td>
 </tr>
<tr>
 <td align="right"><h2><strong>Items: </strong></h2></td>
<td><label>
<div class="hide" id="newscategorylabel"><label class="control-label">Category: </label>
 <?= $form->field($model, 'category')->dropDownList(                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
['id'=>'newscategory', 
'style' => 'width:400px',
])->label(false);?>
  </div>                          
<div class="hide" id="newscommoditylabel"><label class="control-label">Commodity: </label>
<?= $form->field($model, 'commodity')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
 [                                                                        'id'=>'newscommodity', 
'style' => 'width:400px',
 ])->label(false);?>                                   
           </div>
 <div class="hide" id="newsgroupslabel"><label class="control-label" >Groups: </label>                                                  
<?= $form->field($model, 'groups')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),             ['id'=>'newsgroups',                                                             
 'style' => 'width:400px',
 ])->label(false);?>
    </div>
     <div class="hide" id="newsspecieslabel"><label class="control-label" >Species: </label>                                 
<?= $form->field($model, 'species')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),            ['id'=>'newsspecies',         
'style' => 'width:400px',
 ])->label(false);?>                                   
          </div>                                 
<div class="hide" id="newsintendeduselabel"><label class="control-label" >Intended Use: </label>

<?= $form->field($model, 'intendeduse')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
['id'=>'newsintendeduse',                                                             
'style' => 'width:400px',
])->label(false);?>                                   
           </div>                                  
<div class="hide" id="newsoriginlabel"><label class="control-label" >Country of Origin: </label>

<?= $form->field($model, 'origin')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
 [
'id'=>'newsorigin',  
'style' => 'width:400px',
  ])->label(false);?>
   </div>
 <div class="hide" id="newsmanufacturelabel"><label class="control-label" >Manufacture: </label>                
<?= $form->field($model, 'manufacture')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
 [      
'style' => 'width:400px',
])->label(false);?>                                 
 </div>
 <div class="hide" id="newsfinalitylabel"><label class="control-label" >Finality: </label>

<?= $form->field($model, 'finality')->dropDownList(
                                                                    ArrayHelper::map(['empty'=>'Empty string'], 'id', 'value'),
[ 'id'=>'newsfinality',                                                             
'style' => 'width:400px',
  ])->label(false);?>

 </div>
  </label></td>

                </tr>
                <tr>
                    <td align="right"><h2><strong>Status</strong></h2></td>
                    <td><?= $form->field($model, 'status')->dropDownList([ 'Active' => 'Active', 'Restricted' => 'Restricted','Prohibited' => 'Prohibited' ], ['prompt' => 'Select Status','style' => 'width: 400px'])->label(false) ?></td>
                </tr>
                <tr>
                    <td align="right"><h2><strong>News Picture</strong></h2></td>
                    <td><label>
                        <?=$form->field($model, 'img')->fileInput()->label(false);?>
                    </label></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td align="center"><label>
                        <div class="form-group">
                    <?= Html::submitButton($model->isNewRecord ? 'Add News' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
                </div>
                    </label></td>
                </tr>


                </table>
                <br />
                <br />

            </div>   

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

            </div>
<?php

namespace backend\controllers;

use Yii;
use backend\models\News;
use backend\models\NewsSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;


class NewsController extends Controller
{       
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
        ];
    }


    public function actionIndex()
    {

        $searchModel = new NewsSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,

        ]);
    }

    /**
     * Displays a single News model.
     * @param integer $id
     * @return mixed
     */
    public function actionView($id)
    {
        return $this->render('view', [
            'model' => $this->findModel($id),
        ]);
    }

    /**
     * Creates a new News model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
          $timezone = "America/Belize";
        date_default_timezone_set($timezone);

        $model = new News();
         $model->created_date= date('d-m-Y h:i:s a');
        $model->input_user= Yii::$app->user->identity->username;



        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }


    public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }

    public function actionDelete($id)
    {
        $this->findModel($id)->delete();

        return $this->redirect(['index']);
    }


    protected function findModel($id)
    {
        if (($model = News::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}
<?php

namespace backend\models;    
use Yii;    

class News extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public $importcategory;
    public static function tableName()
    {
        return 'news';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['headline', 'story', 'status', 'department', 'input_user', 'created_date'], 'required'],
            [['headline', 'story','importcategory'], 'string'],
            [['img', 'name', 'category', 'commodity', 'manufacture', 'groups', 'species', 'intendeduse', 'origin', 'finality', 'status', 'department', 'input_user', 'created_date'], 'string', 'max' => 255],
            [['department'], 'exist', 'skipOnError' => true, 'targetClass' => Loginusers::className(), 'targetAttribute' => ['department' => 'department']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'headline' => 'Headline',
            'img' => 'Img',
            'story' => 'Story',
            'name' => 'Name',
            'category' => 'Category',
            'commodity' => 'Commodity',
            'manufacture' => 'Manufacture',
            'groups' => 'Groups',
            'species' => 'Species',
            'intendeduse' => 'Intendeduse',
            'origin' => 'Origin',
            'finality' => 'Finality',
            'status' => 'Status',
            'department' => 'Department',
            'input_user' => 'Input User',
            'created_date' => 'Created Date',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDepartment0()
    {
        return $this->hasOne(Loginusers::className(), ['department' => 'department']);
    }
}
function makeIconFromHex() {
    console.log('makeIconFromHex..............');
    console.log(matrix);

    var width = matrix[0].length;
    var height = matrix.length;
}
<?= $form->field($model, 'somefield')
    ->textInput(['hidden'=> $model->isNewRecord ? false : true])
    ->label(false) ?>