当我按下submit按钮时,什么也没有发生,甚至页面都没有刷新。我检查代码的次数太多了。我不知道它有什么问题。我使用的是Yii2框架,basic-app和Apache服务器。
控制器:
<?php
namespace app\controllers;
use Yii;
use yii\web\controller;
use app\models\Form;
class FormController extends Controller{
public function actionForm(){
$model = new Form;
if($
我试图通过口香糖向Yii控制器发出一个帖子请求,但得到一个“坏请求#400”。我认为,当我不使用性价比()时,控制器可以自动被所有类型的请求访问,但不是。我怎么能解决这个问题?在Yii2中,对卷曲/口香糖请求的最佳实践是什么?
class ImportController extends yii\web\Controller {
public function actionIndex() {
return 'OK';
}
}
我在文件夹控制器yii中创建了这样一个控制器
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
class HelloController extends Controller
{
public function actions()
{
return [
'error' => [
'class' =>
我得到这个错误的模型的函数:
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
我创建没有扩展控制器的助手,如下所示
class SomeClass{
public function static SomeMethod(){
//this function for send email
$controller = new \yii\web\Controller();
$controller->renderAjax("template", "array");
}
}
上述代码如何生成Missing argument 1 for yii\base\Controller::__construct(), called in common
我使用yii的基本模板,在Controllers文件夹中手动创建一个新的控制器,并将其命名为CountryController.php,并将下面的代码放入其中。
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
class CountryController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
}
但是,当
我正在将一个在Yii1中开发的旧应用程序迁移到Yii2。
我以前在控制器中有一个数组,该数组存储我需要作为JavaScript发送到前端的所有变量:
public $jsVars;
public function toJSObject($params){
$this->jsVars = array_merge($this->jsVars, $params);
}
private function printJSVarsObject(){
//convert my php array into a js json object
}
当我需要在Javascript中公开一
错误显示not found in production,我认为这可能是因为类尚未导入,或者文件未找到。
但是我已经用
use Yii;
use common\models\TbPesan;
use common\models\TbPesanSearch;
use common\models\TbPesanDest;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\helpers\Url;
use common\component\BeoHelper;
u
我开始安装Yii 2与yii高级-应用程序-2.0.11.tgz档案。在拆包后,我成功地运行了Yii 2高级版。在文件夹项目中,我看到后端和前端应用程序。现在,我想创建诊所应用程序在这里。你能做到吗?我搜索谷歌,但找不到解决方案。
后端和前端
诊所(怎么能做到?)
然后我复制前端目录并命名为“诊所”,然后将所有单词“前端”替换为“诊所”。但我会犯这样的错误:
An Error occurred while handling another error:
exception 'yii\base\InvalidRouteException' with message
我在yii2中创建了一个名为AuthContoller的新控制器。但是控制器操作不起作用。你能在控制器中检查我做错了什么吗?
控制器
<?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\AccessControl;
/**
* Site controller
*/
class AuthController extends Controller
{
public function beforeAction($action){
if (par