在使用Yii2时,我遇到了jquery文件的问题.在布局中我已经注册了一个jquery-1.10.2.min.js文件.但是在内部页面中使用ActiveForm它然后它还包括来自资产的jquery文件.
使用时有没有办法jquery-1.10.2.min.js在任何页面上删除ActiveForm?
非常感谢,
M.
我使用 yii-jui 在视图中添加一些 UI 元素,例如 datePicker。在frontend\config\main-local.php我设置以下内容来更改 JqueryUI 使用的主题:
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'gjhgjhghjg87hjh8878878',
],
'assetManager' => [
'bundles' => [
'yii\jui\JuiAsset' => [
'css' =>
['themes/flick/jquery-ui.css'],
],
],
],
],
];
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法来覆盖控制器操作方法中的此配置项:
public function actions() {
Yii::$app->components['assetManager'] = [
'bundles' => [
'yii\jui\JuiAsset' => [
'css' =>
['themes/dot-luv/jquery-ui.css'],
],
],
]; …Run Code Online (Sandbox Code Playgroud) 谁能有人建议如何"on" => "insert"在yii2中使用验证?我用过
array('field_name', 'required', 'on'=>'insert')
Run Code Online (Sandbox Code Playgroud)
在Yii1但在yii2中它不会检查我是否设置
['field_name', 'required', 'on'=>'insert']
Run Code Online (Sandbox Code Playgroud)
.有什么问题可以解释一下吗?提前致谢.
我正在尝试从View重定向到另一个View,我无法在线找到解决方案.
我尝试过使用:
Yii::$app->request->redirect(Yii::$app->createAbsoluteUrl("site/view"));
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
未知方法 - yii\base\UnknownMethodException
调用未知方法:yii\web\Application :: createAbsoluteUrl()
如何像(id, name) in ((1, 'George'), (2, 'Tom'))使用ActiveRecord的where()条件那样编写复合IN 条件?
假设我有许多在不同时间创建的彩色球,我希望在 GridView 中显示它们。
填充为:
1, red , 2010-10-09
2, blue , 2010-11-08
3, blue , 2010-09-01
4, red , 2010-06-15
Run Code Online (Sandbox Code Playgroud)
默认情况下,我希望首先显示最新的球,但我也希望能够按颜色对球进行排序,因此我在 BallSearch 模型中设置了以下搜索功能:
public function search()
{
$query = Ball::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'attributes' => [
'color',
'created_at',
],
'defaultOrder'=> ['created_at' => SORT_DESC]
],
]);
return $dataProvider;
}
Run Code Online (Sandbox Code Playgroud)
这在一定程度上有效,但是当按颜色排序时,我可以理解地失去了最新的第一个排序。我真的很喜欢这个结果:
2, blue , 2010-11-08
3, blue , 2010-09-01
1, red , 2010-10-09
4, red , 2010-06-15
Run Code Online (Sandbox Code Playgroud)
不幸的是,如果我将最新的第一个条件放在查找查询上:
...
$query = Ball::find()->orderBy(['created_at' …Run Code Online (Sandbox Code Playgroud) 我已经尝试actionError在模块DefaultController中编写自己的,只是为了呈现错误页面(HTML仅用于测试),它也只是显示空白页面而不是显示错误页面.
我在下面做正确的方法吗?仅当我尝试访问模块路径中的不存在页面时,它才显示空白页面.
在我的模块类中,我errorHandler在init()函数中配置了如下组件:
public function init()
{
parent::init();
// initialize the module with the configuration loaded from config.php
\Yii::configure($this, require(__DIR__ . '/config.php'));
\Yii::$app->setComponents([
'errorHandler' => [
'class' => 'yii\web\ErrorHandler',
'errorAction' => 'studconsult/default/error',
] // set error action route - this to be error action in DefaultController
]);
}
Run Code Online (Sandbox Code Playgroud)
在我的DefaultController班上,我的代码如下:
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Yii2 advance 模板,我可以在本地计算机上成功访问 gii 工具。但是当我将其上传到真实服务器时,出现一条消息“您不允许访问此页面”。您能告诉我应该配置哪个文件吗?您可以打印屏幕或粘贴该配置文件的全部内容吗?
先谢谢你了。
yii2 ×8
php ×2
yii ×2
active-form ×1
activerecord ×1
gii ×1
gridview ×1
jquery ×1
oop ×1
sql ×1