_form.php 1.31 KB
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Catalog;

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

<div class="catalog-form">

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

    <?= $form->field($model, 'title')->textInput() ?>
    
	<?= $form->field($model, 'parent_id')->dropDownList(
	        ArrayHelper::map($model->find()->all(), 'parent_id', 'title')
        )
	?> 

    <?= $form->field($model, 'cover')->textInput(['maxlength' => true]) ?>
  
    <?= $form->field($model, 'status')->dropDownList([
            '1' => Yii::t('action', 'show'), 
            '0' => Yii::t('action', 'hide'),
        ]);
 
    echo '<pre>';

    $array = $model->findInfo([
        'catalog_id' => 1,  
        'return_one' => true,
        'to_array' => false,
    ]);
    
    var_dump($array->relationCatalogLang2->title);
    //var_dump($array->relationCatalogLang2->title);
    
    echo '</pre>';

    ?> 

    <?= $form->field($model, 'sort')->textInput() ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('action', 'add') : Yii::t('action', 'update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

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

</div>