2016-07-02 8 views
3

を見つけていないし、私はこのエラーaccross来て、私はそれの原因を見つけることができません。その後Yiiの基本404ページのYiiして、私は非常に新しい

SiteController.php

public function actionUserForm(){ 


     $model = new UserForm(); 


     if($model->load(Yii::$app->request->post()) && $model->validate()){ 


     }else{ 

     return $this->render('userform', [ 
      'model' => $model, 
     ]); 
     } 
    } 

UserForm.php(モデル)

<?php 

namespace app\models; 


use yii\base\Model; 


class UserForm extends Model{ 
    public $name; 
    public $email; 


    public function rules(){ 
    return [ 
     [['name', 'email'], 'required'], 
     //email form should look like an email 
     ['email', 'email'], 
    ]; 
    } 
} 

userform.php(ビュー)

<?php 
use yii\helpers\Html; 
use yii\widgets\ActiveForm; 
?> 


<?php 

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

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

<?= 
Html::submitButton('Submit', [ 
    'class' => 'btn btn-success' 
]); 

?> 



    ?> 

結果のページには、次のようになります。問題の特定に役立ち、コード内のエラーを親切に指摘できますか?私はこのフレームワークには非常に新しいので、私はまだそれのための感じを得るために始めています。 enter image description here

これは私が今それをアクセスしていますがどのようです。 enter image description here

私は、あまりにもURLをクリーンアップする.htaccessファイルを持っています。

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule . index.php 

次に、web.phpでこれを削除する手順2でした。これらは実際にフォームを作成する前に私が行ったことです。

'urlManager' => [ 
      'enablePrettyUrl' => true, 
      //this will remove index.php in the url 
      'showScriptName' => false 
      //this is a two step process, after this go to the .htaccess in the web directory 
     ] 
+0

が小さい作成http://www.yiiframework.com/doc-2.0/guide-start-hello.html cameCaseが、-マイナスの区切りではありませんコードをテストし続けてください。 – unixmiah

+0

は、ユーザーフォームが – scaisEdge

+0

限り私の理解は、このコードに誤りがないしてくださいコールに使用するあなたの正確なリンク/ URLが表示されます。 @Scais Aksedのように、あなたのURLを入力してください。あなたはそれにアクセスする方法。 –

答えて

1

Yii2のURLにアクセスするための正しい方法は

... web/site/user-form 
関連する問題