调用其他形式索引在Yii2先进


Calling other forms to index in Yii2 advanced

大家好!我想把表格从联系形式到索引页。但我不知道怎么做。以下是contact-form的代码:

/*create.php*/
<?php
use yii'helpers'Html;
$this->title = 'Create Contact Form';
$this->params['breadcrumbs'][] = ['label' => 'Contact Forms', 'url' =>
['index']];
$this->params['breadcrumbs'][] = $this->title;?>
<div class="contact-form-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', ['model' => $model,]) ?>
</div>
/*_form.php*/
<?php
use yii'helpers'Html;
use yii'widgets'ActiveForm; ?>
<div class="contact-form-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'sender_name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sender_email')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'subject')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'content')->textarea(['rows' => 6]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update'
, ['class' => $model->isNewRecord ? 'btn btn-success' : '
btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

代替

<?= $this->render('_form', ['model' => $model,]) ?>

<?= 'Yii::$app->view->render('@frontend/views/contact-form/_form', ['model'=> $model) ?>