dsn5510 2016-08-11 02:29
浏览 50

在yii2中未能成型

I have added this code in my editor the location is in app\models\FormAntri

<?php

  namespace app\models;

  use Yii;
  use yii\base\Model;

  class FormAntri extends Model
  {
 public $nama;
 public $email;

 public function rules()
 {
  return [
  [['nama', 'email'], 'required'],
  ['email', 'email'],
];
}
}

this code also in app\models\controllers/SiteController

public function actionAntri()
{
  $model = new FormAntri();

  if ($model->load(Yii::$app->request->post()) && $model->validate()){
    return $this->render('antri-ok',['model' => $model]);
  }else{
    return $this->render('antri', ['model' => $model]);
  }
}

I also added this code in views/site/antri.php

<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'nama') ?>
<?= $form->field($model, 'email') ?>

<div class="form-group">
 <?= Html::submitButton('Ok', ['class' => 'btn btn-primary']) ?>
</div>

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

I added this too in view/site/antri-ok.php

<?php
use yii\helpers\Html;
?>
<p>Informasi yang sudah anda kirim adalah :</p>

<ul>
  <li><label>Nama</label>: <?= Html::encode($model->nama) ?></li>
  <li><label>Email</label>: <?= Html::encode($model->email) ?></li>
</ul>

but when I run http://localhost/advanced/backend/web/index.php?r=site/antri the result came like this enter image description here

what's wrong with that?

  • 写回答

2条回答 默认 最新

  • dousi4257 2016-08-11 03:02
    关注

    It is authorized to issue, comments, behaviors method to try again

    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统