Yii

yii2 form validation not working

非 Y 不嫁゛ 提交于 2019-12-25 04:26:08
问题 How to know if the validation has been triggered in yii2 active form? I am using $('#formId').yiiActiveForm('validate', true); to validate the form, but it always returns undefined. 回答1: Trigger the form validation try this : var $form = $("#formId"), data = $form.data("yiiActiveForm"); $.each(data.attributes, function() { this.status = 3; }); $form.yiiActiveForm("validate"); I've create a function to validating active form in javascript, it will be return true/false. Maybe usefull : function

Yii Framework: setPathOfAlias() returns null

穿精又带淫゛_ 提交于 2019-12-25 04:24:15
问题 I am trying to put MaxMind's GeoIp2 into my Yii application. Basically, I copied the files under "src" (see previous link) under protected -> vendors -> maxmind . The folder structure under my application is the following: protected |---- vendors |---- Zend |---- maxmind |---- Database |---- Reader.php |---- Model |---- ... |---- ... After that, I created the path aliases into my index.php file: Yii::setPathOfAlias('Zend', Yii::getPathOfAlias('application.vendors.Zend')); Yii::setPathOfAlias(

Geolocation API - wait for getting position

谁说我不能喝 提交于 2019-12-25 04:15:47
问题 I just wonder what is the correct Geolocation API usage for the following use case: I have website (targeted to mobile phones) with some form. User enters some text and press "Submit". I need to record user's location (GPS coordinates) together with the entered data and (important!) raise some warning message if user didn't give permission or we were unable to determine his\her position. From my point of view the problem is that Geolocation API is asynchronyous. So after pressing "Submit"

Yii framework: wrong creating urls

 ̄綄美尐妖づ 提交于 2019-12-25 04:08:07
问题 I'm learning Yii and got into url creating problem. I have a component urlManager as follows: 'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 'admin/useredit/<id:\d+>'=>'admin/useredit', ), 'showScriptName'=>false, 'urlSuffix'=>'.html', ), When I use this: $this->createUrl('admin/useredit',array('id'=>'2')) It

Database connection error in Yii

百般思念 提交于 2019-12-25 03:45:08
问题 I'm going through the Yii tutorial on creating a blog and following the steps. For the database I just imported the test database. Everything was fine. When I made connection with the database in main.php it is showing the following error: CDbConnection failed to open the DB connection: SQLSTATE[42000] [1049] Unknown database 'myblog' The database connection array in main.php is: //'db'=>array( // 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', //), // uncomment the

yii CMultiFileUpload stop default behavior

一世执手 提交于 2019-12-25 02:43:07
问题 How are you supposed to prevent the CMultiFileUpload widget from appending the file names of selected files to the page? Here is my code: <?php $this->widget('CMultiFileUpload', array( 'name' => 'images', 'accept' => 'jpeg|jpg|gif|png', 'denied' => 'Invalid file type', 'htmlOptions' => array('multiple'=>'multiple'), ));?> Here is a picture of what I am talking about: I need to remove what the arrows point to. It's also strange why it says "No files selected" when that isn't the case. If I

Error causes password change while updating new data in Yii

淺唱寂寞╮ 提交于 2019-12-25 02:39:14
问题 While I'm trying to update the AID field in database with this function: static function aidInsert() { $model = Users::model()->findAll(); foreach($model as $m) { $code = alphabeticCode(); $aidk = Users::model()->findByAttributes(array('aid'=>$code)); if(!empty($aidk)) { $code = alphabeticCode(); } $m->aid = $code; $m->save(); } } (alphabeticCode Method is just a method used to generate random strings.) the whole user's password stored in password field is completely changed into some piece

Flash Player Does not Show up on Firefox but not Chromium

好久不见. 提交于 2019-12-25 02:39:07
问题 Am trying to make audio Player extension and I choose to wrap Wordpress Audio found here So Far I have it working on all Webkit based browsers but not on firefox. I have tried to put auto start on and I can hear audio in firefox which tells me that flash and JS code loads fine but does not show up (see attached images). I have tried all options in my head and did not work. This is my very first extension so forgive anything that is obvious and point out to me please. Here are images Here is

How to format numeric string using C.Gridview - Yii

旧城冷巷雨未停 提交于 2019-12-25 02:26:18
问题 I've recently run into the issue where I have a string of numbers (totaldue) that I would like to format in my C.Gridview so that 10000 would become 10,000 So far I have done this $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'paylist-grid', 'dataProvider'=>$dataProvider, 'filter'=>$model, 'columns'=>array( 'totaldue'=> array( 'value'=>'totaldue', 'type'=>'number'), // more code ... This would work if total due was a int or double, but because it is a string, I am getting thrown an

Yii not redirecting properly with the CController::redirect() function

醉酒当歌 提交于 2019-12-25 02:18:18
问题 In a yii site I am creating I have a page with the url http://localhost/administrator/restaurant/list which shows the list of restaurants in a tabular format along with a delete button. The delete button points to http://localhost/administrator/restaurant/delete/<id> . The actionDelete of my controller is as follows : public function actionDelete(){ $model = Restaurants::model()->findByAttributes( array( 'id'=>$_GET['id'], 'clientId'=>Yii::app()->user->clientId )); $model->delete(); Yii::app(