Yii

Yii - Catch all incoming requests

北城余情 提交于 2019-12-23 04:18:24
问题 Is there a way in Yii to catch and act upon all incoming requests are when functions are fired. I want to right an e-mail extension that can be set to something like, when documents/update is fired or function SaveDocument is fired send e-mail x. I guessing that i can do this by extending the Controller class but that is already being done by the rights extension. Thanks for any suggestions. 回答1: create a class filter protected/filter/EmailFilter EmailFilter extends CFilter{ //fired before

Auto complete fields of a previous values

这一生的挚爱 提交于 2019-12-23 04:05:11
问题 I am doing a small application in Yii Framework for that my database is something like this === Invoices === id (PK) customer_id invoice_title order_no invoice_issue_date due_date description === Customers === id (PK) email_address customer_name address city state postal_code description I have rendered the Customer model in Invoice model so that I can enter all the values for both models in a single Invoice form .But there is one problem,let us assume that I have a customer name xyz which I

Preserve Session on Logout and Login

旧街凉风 提交于 2019-12-23 03:54:14
问题 I print out the session ID like this: <?php print YII::app()->session->sessionID; ?> When I log-in and check my ID , it is something like: huh09vuo33scdlkmfuc8651t12 , for example. If I log out and check again, my ID remains the same. However, if I then log back in again, the session ID changes! My problem is that I have information in my session that I need to store in a cookie and reload after login. How can I uniquely establish that the user logged in is the correct user if his session ID

Yii Bootstrap not loading JS files

别说谁变了你拦得住时间么 提交于 2019-12-23 03:49:08
问题 I'm using Yii-Bootstrap in my brand new Yii project. I followed the install instructions exactly. On the front page I am using the JS Carousel plugin. $this->widget('bootstrap.widgets.TbCarousel', array( 'items'=>array( array( 'image'=>'http://placehold.it/770x400&text=First+thumbnail', 'label'=>'asdf', 'caption'=>'Cras justo odio, ' ), array( 'image'=>'http://placehold.it/770x400&text=Second+thumbnail', 'label'=>'asdf', 'caption'=>'Cras justo odio, ' ), array( 'image'=>'http://placehold.it

Url parameters values with special characters are providing errors in view

本小妞迷上赌 提交于 2019-12-23 03:41:18
问题 I have edited Url manager to provide SEO friendly urls but getting problem when the url have values with special characters such as . or () or - or any other special character http://localhost/nbnd/search/city/delhi In city action var_dump($_GET); output: array(1) { ["city"]=> string(6) "delhi" } but when url is with some special character http://localhost/nbnd/search/city/north-delhi or http://localhost/nbnd/search/city/north.delhi or http://localhost/nbnd/search/city/(north)delhi In city

In Yii2 framework, better place to define common function which is accessible everywhere like controller, model, view

做~自己de王妃 提交于 2019-12-23 03:26:42
问题 Like i want to create function with name "dt()" function dt(){ return date('Y-m-d H:i:s'); } and want to access it like this:- echo dt(); //retrun current date and time format Which is better place in Yii2 framework to do that? 回答1: You can use it this way: http://www.yiiframework.com/extension/yii2-helpers/ Create a folder /common/helpers/ , then create a helper class there and add your static methods. namespace common\helpers; class DateHelper { public static function dt(){ return date('Y-m

Yii generate model without Gii

做~自己de王妃 提交于 2019-12-23 03:12:16
问题 I need to generate a model file without the use of Gii. Are there any command Yii? $table = "myTable"; Yii::app()->generateModel($table); // ? 回答1: Perhaps is officially deprecated, you can generate code with Yii Command Line Tools I have tested it with Yii 1.1.17. First you need to create a new file on protected/commands called for example NewmodelCommand.php to create a new yii command. We need to avoid to use shell interactive tool and call command directly from our code in controllers,

Yii generate model without Gii

牧云@^-^@ 提交于 2019-12-23 03:12:03
问题 I need to generate a model file without the use of Gii. Are there any command Yii? $table = "myTable"; Yii::app()->generateModel($table); // ? 回答1: Perhaps is officially deprecated, you can generate code with Yii Command Line Tools I have tested it with Yii 1.1.17. First you need to create a new file on protected/commands called for example NewmodelCommand.php to create a new yii command. We need to avoid to use shell interactive tool and call command directly from our code in controllers,

New record isn't saved and no error messages

拟墨画扇 提交于 2019-12-23 02:51:10
问题 I am trying to save a new row into a quote, but Yii doens't save the QuoteRow. It only saves the new service (Yes the DB-structure is a bit weird). I can't seem to figure it out. If the row doesn't get saved, $qr->save() should return false but it doesn't. The service is successfuly inserted, however the quoterow isn't. $service = new Services; $service->label = $row['title'] ?: "Övrigt"; $service->is_priced_per_unit = 1; $service->price_per_unit = $row['price']*0.8; $service->is_default = 0;

Yii redirecting the admin and authenticated user to the desired page

纵饮孤独 提交于 2019-12-23 02:49:17
问题 I am new to yii. I want my admin upon login from webapp/user/login to redirect to the page I want which is localhost/webapp/story right now it is redirecting me to the index.php. I have also registered a user and given that user a role which is authenticated and I want that when my user(the authenticated user) logs in via webapp/user/login then that user is redirected to index.php. so there are two things: 1. redirecting admin to the desired page which is webapp/story. 2. redirecting the