我想在表格的第七位添加一列,我正在使用
$this->addColumn('table_name','column_name','type');
Run Code Online (Sandbox Code Playgroud)
最后添加列.有什么方法我可以提到添加列的地方吗?或者在列之后的任何关键字关键字中添加我的新列,例如,密码列.我从Yii Doc那里学到了很多移民
我有一个用户注册表单,我试图通过使用Yii小部件CCaptcha显示Captcha图像,但是我的图像链接显示已损坏,控制器文件:
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
);
}
Run Code Online (Sandbox Code Playgroud)
模型文件:
public function rules()
{
return array( array('verifyCode','captcha','allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'insert'),
);
}
Run Code Online (Sandbox Code Playgroud)
并查看文件:
<?php if(CCaptcha::checkRequirements()): ?>
<div class="row">
<?php echo $form->labelEx($model,'verifyCode'); ?>
<div>
<?php $this->widget('CCaptcha'); ?>
<?php echo $form->textField($model,'verifyCode'); ?>
</div>
<div class="hint">Please enter the letters as shown.
<br/>Letters are not case-sensitive.</div>
<?php echo $form->error($model,'verifyCode'); ?>
</div>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
作为某处提供的答案,我也尝试在我的控制器文件中提供访问规则
public function accessRules()
{
return array( …Run Code Online (Sandbox Code Playgroud) 我试图删除Yii中的一条记录,它会抛出错误400.请不要再重复此请求.它正在检查一个post变量,我的控制器文件有
if(Yii::app()->request->isPostRequest)
当我回显我的post变量时它是空白而$ _GET有我要删除的id,我的View文件看起来像,
echo CHtml::link(CHtml::encode('Delete image'), array('image/delete', 'id'=>$image->id), array('class' => 'delete','confirm'=>'This will remove the image. Are you sure?'));
Run Code Online (Sandbox Code Playgroud)
访问规则已删除已通过身份验证的用户,这是正确的.也试了一下*.我也尝试将其作为隐藏变量发送,但没有好处.
无法弄清楚我应该如何在Yii中发布表格.
我是Yii以及Twitter Bootstrap的新手,我正在尝试使用bootstrap提供的文件.我已经将下载的文件夹解压缩到Yii中受保护文件夹的扩展目录中,然后按照http://www.cniska.net/yii-bootstrap/setup.html#setup我的main.php中的代码如下所示:
'preload'=>array('log','bootstrap'),
'import'=>array(
...
'application.extensions.bootstrap.widgets.*',
),
'modules'=>array(
'generatorPaths'=>array(
'bootstrap.gii',
),
),
'components' => array(
'bootstrap'=>array(
'class'=>'ext.bootstrap.components.Bootstrap',
),
),
Run Code Online (Sandbox Code Playgroud)
我得到此错误
别名"ext.bootstrap.components.Bootstrap"无效.确保它指向现有的PHP文件.
Q2.除了在Yii的CSS中复制粘贴整个bootstrap css文件之外,还有更好的方法吗?
Q3.我是否必须下载任何额外的内容才能使用bootstrap twitter提供的小部件,例如$ this-> widget('ext.cssmenu.CssMenu',array(...);下载的文件应该放在哪里?