3
나는 yii에 매우 익숙하며이 오류가 발생하여 그 원인을 찾을 수 없습니다.Yii 기본 404 페이지를 찾을 수 없음
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'
]);
?>
?>
. 문제를 파악하고 코드의 오류를 친절하게 지적 할 수 있습니까? 나는이 프레임 워크에 대해 매우 새롭기 때문에 아직도 그것에 대한 느낌을 갖기 시작했습니다.
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
]
작게 만들 http://www.yiiframework.com/doc-2.0/guide-start-hello.html cameCase하지만
-
마이너스 세퍼레이터 아니다 테스트 베드를 작성하고 코드를 작성하십시오. – unixmiah정확한 링크/url을 사용하여 UserForm을 호출하십시오. – scaisEdge
제 생각에는이 코드에는 오류가 없습니다. @skais Aksed처럼 URL을 입력하십시오. 당신이 어떻게 접근했는지. –