简体   繁体   English

PHP_SELF在yii动作中

[英]PHP_SELF in yii action

How do you add in the yii form the action for PHP_SELF, I am currently using this: 您如何在yii表单中添加PHP_SELF的操作,我目前正在使用它:

'action' => '/site/contact',

but I want to replace the action to call itself again. 但我想替换该操作以再次调用自身。 How do I do that? 我怎么做?

UPDATE: 更新:

tried removing the action in the array, now it does not go into validating the form. 尝试删除数组中的操作,现在它不验证表单。

Use Yii controller method createUrl - calling it without params will point to current controller and action. 使用Yii控制器方法createUrl不带参数的调用将指向当前控制器和操作。

In views you can just call $this->createUrl() : 在视图中,您可以只调用$this->createUrl()

'action' => $this->createUrl(),

Important : do not hardcode actions like in your question. 重要提示 :请勿对问题中的操作进行硬编码。 Always call createUrl , this will ensure proper urls if you change url rules: 始终调用createUrl ,如果您更改url规则,这将确保正确的url:

'action' => $this->createUrl('otherController/someAction'),

or same controller different action 或同一控制器的不同动作

'action' => $this->createUrl('otherAction'),

etc. 等等

Do mean perhaps a page refresh? 是否意味着刷新页面?

Just do $this->refresh() inside your controller action. 只需在控制器操作中执行$this->refresh()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM