CHtml :: button('Update',array('submit'=> array('link/update',array('id'=> $ data-> linkId)))
提交的网址
本地主机/ yiiTest2 /的index.php?R =链路/更新&0%5Bid%5D = 5
如何删除这个0%5B和%5D ????
问:登录后如何重定向到不同的页面?
状态:我有自定义用户角色,我想为不同的用户重定向到不同的页面.
例如,人力资源经理 - >员工/指数,客户经理 - >账户/指数.
我正在使用yii 1.1.xx和权限模块.yii和权利模块是绿色的.
更新问题的信息
这是等级tbl

这是用户tbl

如果排名是客户经理,则网站将重定向到帐户/索引.
如果排名是HR经理,则网站将重定向到员工/索引.
yii cactivedataprovider指定了默认排序,但使用AJAX排序的前台无效.使用sortableattributes排序无效
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$article = new CActiveDataProvider('article',array(
'criteria'=>array(
'order'=>'id DESC',
),
'pagination'=>array(
'pageSize'=>15,
),
));
$this->render('index',array('article'=>$article));
}
$this->widget('bootstrap.widgets.TbListView', array(
'dataProvider'=>$article,
'itemView'=>'_list', // refers to the partial view named '_post'
'template'=>'{sorter}{items}{pager}{summary}',
'sortableAttributes' => array(
'id',
'date'
)
Run Code Online (Sandbox Code Playgroud) 我刚刚安装了yii-user-management模块,但当我尝试通过浏览器访问它时,我得到了
致命错误:在第368行的..../modules/user/models/YumUser.php中的非对象上调用成员函数get()
$relations = Yii::app()->cache->get('yum_user_relations');
Run Code Online (Sandbox Code Playgroud)
感谢任何帮助.
我试图使用yii的bootstrap扩展,但我不断收到标题中提到的错误,我仔细检查了我的配置文件,但我不知道我在做错了.这是我的config/main.php
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'language'=>'en_us',
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'CODEPAC',
// preloading 'bootstrap,log' component
'preload'=>array('bootstrap','log',),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'user'=>array(
'debug'=>false,
'userTable'=>'user',
'translationTable'=>'translation',
'mailer'=>'PHPMailer',
'facebookConfig'=>array(
'appId'=>'12345',
'secret'=>'secret',
'domain'=>'localhost',
'status'=>true,
'xfbml'=>true,
'cookie'=>true,
'lang'=>'en_US',)
),
'avatar'=>array(),
'profile' => …Run Code Online (Sandbox Code Playgroud) 我有以下表格用于创建新记录
<?php
/* @var $this ComponentsController */
/* @var $model Components */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'components-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'component_id'); ?>
<?php echo $form->textField($model,'component_id'); ?>
<?php echo $form->error($model,'component_id'); ?>
</div>
<div class="row">
<label class="required" for="FixedAsset_original_asset_number">
Asset Number
</label>
<input id="Components_original_asset_number" type="text" name="Components[original_asset_number]">
<?php //echo Chtml::textField('fixed_asset_id', FixedAsset::model()->FindByPk($model2->fixed_asset_id)->fixed_asset_id); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'description'); ?>
<?php echo $form->textField($model,'description',array('size'=>60,'maxlength'=>255)); …Run Code Online (Sandbox Code Playgroud) 我需要在Yii中验证一些变量值;
我没有model,我需要一个预制yii public method.
其中一些必须是整数,其他字符串;
这些值是通过GET传递的.
我尝试了所有的yii所有的验证类,但都没有.
有没有人试过这个并成功了?
我需要这样的东西:
$validator = new CValidator();
$result = $validator->validate(array($key=>$value));
Run Code Online (Sandbox Code Playgroud)
开放为sugestions
使用Yii 1.1.12.我有一个关闭ajax 的CListView:
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'ajaxUpdate' => false,
)); ?>
Run Code Online (Sandbox Code Playgroud)
链接到第二页的网址如下所示:
http://www.example.com/products?Product_page=2
我希望网址看起来像:
http://www.example.com/products?page=2
我怎样才能做到这一点?
(奖励也是描述如何得到一个网址http://www.example.com/products/page/2)
更新
正如elbek所指出的,我看到CListView有一个pager类型为CLinkPager的属性.这又具有CPaginationpages类型的属性,其具有属性pageVar,其描述为:
存储当前页面索引的GET变量的名称.默认为"页面".
听起来它可能是我正在寻找的,但不知道如何从CListView修改它.
我在Yii有四个模特.汽车,赛车,豪华汽车和司机.
RaceCar has_one Driver
LuxuryCar has_one Driver
RaceCar和LuxuryCar都继承了相同的模型 - Car - 使用相同的表继承.
LuxuryCar和RaceCar中都有一个"fuel_level"属性,用于更改Driver中的验证规则(如果RaceCar.fuel_level为零,则Driver不能将属性"action"设置为"driving").
而不是必须添加每个可能的"属于"关系驱动程序(我可能会添加更多继承的汽车模型),然后检查以查看驱动程序当前属于哪种汽车,以便我可以从数据库加载模型再次,我希望能够验证父级中Driver的属性值(例如RaceCar).
这可能吗?如果是这样,怎么样?如果没有,是否有更好的方式让我失踪?