yii-events

Non-Editable Text-Field

早过忘川 提交于 2019-12-23 09:29:54
问题 I am new in YII , i am wondering if the text-field in YII can made non-editable. If so can anyone answer. I do the following way.. <?php echo $form->labelEx($model,'first_name'); ?> <?php echo $form->textField($model,'first_name',array('setEnabled' => false)); ?> This is not working. 回答1: Use readonly instead: <?php echo $form->textField($model,'first_name',array('readonly' => true)); ?> For no blinking, go for disabled attribute: <?php echo $form->textField($model,'first_name',array(

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

Yii multiple file upload

人盡茶涼 提交于 2019-12-11 17:52:27
问题 hi i am doing multiple file upload in yii... i have setup form to use multiple file upload like this... myfrom.php <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'topic-form', 'enableAjaxValidation'=>false, 'htmlOptions' => array('enctype' => 'multipart/form-data'), // ADD THIS )); ?> <div class="row"> <?php $this->widget('CMultiFileUpload', array( 'name' => 'imagepath', 'model'=> $model, 'id'=>'imagepath', 'accept' => 'jpeg|jpg|gif|png', // useful for verifying files 'duplicate'

How to use transactions in Yii event

不打扰是莪最后的温柔 提交于 2019-12-11 05:27:18
问题 I know, how to use transactions in pure DAO or in ActiveModel, where transaction is initiated before call to $model->save() and rolled back upon any exception. But how to use transactions, if the only place of code I have access to (no matter, why) is Yii event? public function beforeDelete() { foreach($this->menuItems as $menuItem) $menuItem->delete(); return parent::beforeDelete(); } If I initiate transaction there, capture possible exception and rollback entire transaction upon it, then

HTML Button calling controller/action

 ̄綄美尐妖づ 提交于 2019-12-10 23:43:38
问题 I am trying to create html button in Yii on button click I want to call a UserController.php and Actioncreate . I am doing like this , echo CHtml::button('Signup', array('button' => array('Users/create'))); ?> But it's giving me following error htmlspecialchars() expects parameter 1 to be string, array given This is stack trace D:\wamp\www\yii\framework\web\helpers\CHtml.php(85) 73 */ 74 public static $liveEvents = true; 75 76 /** 77 * Encodes special characters into HTML entities. 78 * The {

Hidden Pagination summary text

∥☆過路亽.° 提交于 2019-12-08 04:55:54
问题 I use CGridView in Yii to create tables. I would like to show my table with pagination but hide the summary text at the top, which indicates the number of page restance (Displaying 1-4 of 4 results.) Is that possible? thank you Sorry for my English 回答1: There is a template option. By default it equals {summary}\n{items}\n{pager} If you override it in your gridview config, you'l be able to remove summary section: $this->widget( 'zii.widgets.CGridView', array( Your options here ... 'template' =

Auto complete fields of a previous values

早过忘川 提交于 2019-12-07 00:22:30
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 had saved before .Now when I am going to again fill the Customer name with xyz ,it should show all the

YII compress your application output using gzip

偶尔善良 提交于 2019-12-06 07:39:14
问题 what is the benefit of below code that is two events. what its actually doing ?? require_once($yii); $app = Yii::createWebApplication($config); Yii::app()->onBeginRequest = function($event) { return ob_start("ob_gzhandler"); }; Yii::app()->onEndRequest = function($event) { return ob_end_flush(); }; $app->run(); please explain the function of this code in my application.what it does ?? and how can it help me ?? 回答1: The above code buffers the content and gzips it according to browser, rather

YII compress your application output using gzip

蹲街弑〆低调 提交于 2019-12-04 16:30:25
what is the benefit of below code that is two events. what its actually doing ?? require_once($yii); $app = Yii::createWebApplication($config); Yii::app()->onBeginRequest = function($event) { return ob_start("ob_gzhandler"); }; Yii::app()->onEndRequest = function($event) { return ob_end_flush(); }; $app->run(); please explain the function of this code in my application.what it does ?? and how can it help me ?? The above code buffers the content and gzips it according to browser, rather than sending it straight away. Yii::app()->onBeginRequest = function($event) { return ob_start("ob_gzhandler"

Foreign Key not storing in Yii

北慕城南 提交于 2019-12-01 12:22:14
I have adatabase like this ====Group===== id name ====Member==== id group_id firstname lastname membersince Now as group_id is foreign key then when I will save Group tabale then the group_id should be save with that number. In relations I have made relations for Group is public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'member' => array(self::HAS_MANY, 'Member', 'groupid'), ); } In Member Model my relations is just like this public function relations() { // NOTE: you may