天道酬勤,学无止境

yii-events

Yii多文件上传(Yii multiple file upload)

问题 嗨,我正在 yii 中上传多个文件... 我有设置表单来使用这样的多个文件上传... 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' => 'Duplicate file!', // useful, i think 'denied' => 'Invalid file type', // useful, i think )); ?> <div class="row buttons"> <?php echo CHtml::submitButton($model-

2021-11-11 16:14:20    分类:技术分享    php   yii   yii-events

Yii multiple file upload

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' => 'Duplicate file!', // useful, i think 'denied' => 'Invalid file type', // useful, i think )); ?>

2021-11-11 02:25:05    分类:问答    php   yii   yii-events

Yii事件中如何使用事务(How to use transactions in Yii event)

问题 我知道,如何在纯 DAO 或 ActiveModel 中使用事务,在调用$model->save()之前启动事务并在出现任何异常时回滚。 但是如何使用事务,如果我可以访问的唯一代码位置(不管,为什么)是 Yii 事件? public function beforeDelete() { foreach($this->menuItems as $menuItem) $menuItem->delete(); return parent::beforeDelete(); } 如果我在那里启动事务,捕获可能的异常并在其上回滚整个事务,那么只会回滚关系模型(此处:菜单项)的删除。 它不会阻止(回滚)主记录的删除。 是否通过在我自己的beforeDelete中返回FALSE来防止删除主记录,以防万一,这是我需要注意的全部吗? 或者我应该在 Yii 事件中完全避免交易吗? 回答1 覆盖保存方法怎么样: public function save($runValidation=true,$attributes=null) { $transaction=$this->getDbConnection()->beginTransaction(); try { $result = parent::save($runValidation,$attributes); if($result)

2021-10-10 03:06:52    分类:技术分享    yii   transactions   yii-events

How to use transactions in Yii event

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 only deletion of relational models (here: menu items) will be rolled back. It will not prevent (roll back

2021-10-10 02:17:13    分类:问答    yii   transactions   yii-events

隐藏分页摘要文本(Hidden Pagination summary text)

问题 我在 Yii 中使用 CGridView 创建表格。 我想用分页显示我的表格,但隐藏顶部的摘要文本,该文本指示页面静止的数量(显示 4 个结果中的 1-4 个。) 那可能吗? 谢谢 对不起我的英语不好 回答1 有一个template选项。 默认情况下它等于{summary}\n{items}\n{pager} 如果您在 gridview 配置中覆盖它,您将能够删除摘要部分: $this->widget( 'zii.widgets.CGridView', array( Your options here ... 'template' => '{items}\n{pager}', ) ); 回答2 另一种选择是将CGridView summaryText值设置为 false 回答3 因为YII使用了CListView,所以也在asset文件夹中添加了一定的汇总类CSS。 因此,要解决此问题,只需覆盖 css。 将此添加到您的 CSS。 #yw0>.summary{ display:none; }

2021-08-10 20:07:04    分类:技术分享    yii   yii-components   yii-events

自动完成先前值的字段(Auto complete fields of a previous values)

问题 我正在 Yii 框架中做一个小应用程序,因为我的数据库是这样的 === 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 我已经在Invoice model渲染了Customer model ,以便我可以在一个single Invoice form输入两个模型的所有值。但是有一个问题,让我们假设我有一个我之前saved before的客户名称xyz 。现在当我将again fill the Customer name with xyz ,它应该all the fields of both models like invoice_title,order_no,invoice_issue_date,due_date,description,email_address,customer_name,address etc. in that input fields of the form显示all the fields of both models

2021-07-10 00:37:53    分类:技术分享    php   mysql   yii   yii-events

Hidden Pagination summary text

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

2021-07-02 05:58:08    分类:问答    yii   yii-components   yii-events

Auto complete fields of a previous values

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

2021-06-29 00:35:52    分类:问答    php   mysql   yii   yii-events

Foreign Key not storing in Yii

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

2021-05-06 15:20:55    分类:问答    php   yii   yii-events

How to use events in Yii

I want to run some code in the onBeginRequest event. Where do I do that? I assume I am not suppose to add this in the core library code. I am a totally noob in Yii

2021-04-27 03:46:01    分类:问答    php   yii   yii-events