简体   繁体   中英

PHP_SELF in yii action

How do you add in the yii form the action for PHP_SELF, I am currently using this:

'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.

In views you can just call $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:

'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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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