yii2

Yii2- Unable to upload image

三世轮回 提交于 2019-12-20 03:19:29
问题 I am working on yii2 . In one of my view, I am trying to upload an image. But I am unable to upload it. Model class MeterAcceptanceHeader extends \yii\db\ActiveRecord { public static $status_titles =[ 0 => 'Prepared', 1 => 'Created', 2 => 'Printed', 3 => 'Canceled', ]; /** * @inheritdoc */ public static function tableName() { return 'meter_acceptance_header'; } /** * @inheritdoc */ public function rules() { return [ [['sub_div', 'prepared_by'], 'required'], [['prepared_by', 'updated_by'],

Yii2 disable asset of a vendor module

﹥>﹥吖頭↗ 提交于 2019-12-20 01:46:18
问题 I have installed yii2-admin module, located in /vendor/mdmsoft/yii2-admin but I don't want it to load its own asset bundle. It there any way to disable this module asset bundle? 回答1: Yes, it's possible and even mentioned in official docs here. One way to do it is through application config: return [ // ... 'components' => [ 'assetManager' => [ 'bundles' => [ 'mdm\admin\AdminAsset' => false, ], ], ], ]; Another way - during runtime through component: \Yii::$app->assetManager->bundles['mdm

Count all record in table in yii2 without where clause

老子叫甜甜 提交于 2019-12-20 01:39:03
问题 I want to count all record from table without specify any condition : now, i am doing by this way $result['cms'] = Cms::find()->where([])->count(); and it will give me result,but i don't want to use where clause. So how to count all records without where clause. Thank you 回答1: You can see this doc http://www.yiiframework.com/doc-2.0/yii-db-activequery.html simply using count(): returns the result of a COUNT query. Cms::find()->count(); all(): returns an array of rows with each row being an

How to set Yii2's ActiveForm checkbox in checked state?

好久不见. 提交于 2019-12-19 19:52:21
问题 I'm looking for a simple solution for a "checked" state for the Yii2 ActiveForm checkbox control and I can't find a solution how to set it. I cant find any examples in the documentation. I've tried to manipulate the rendering code <?= $form->field($model, 'name')->checkbox()->label('Hi'); ?> But it seems I need to modify the ActiveForm itself. How to make checkbox checked by default? 回答1: Ok, I've debbuged a while and found a solution, it lies in the guts of BaseHtml.php at line 1359 in

how to Json encode in yii2?

北城以北 提交于 2019-12-19 17:38:21
问题 Attempting to encode json and receive 400: Bad Request in yii2 . I am trying to encode in Rest client but it is not working properly. <?php namespace app\controllers; use Yii; use yii\filters\AccessControl; use yii\web\Controller; use yii\filters\VerbFilter; use app\models\TblUserRegistration; class UserController extends Controller { public function actionRegister() { $model = new TblUserRegistration(); $username = $_POST['username']; echo json_encode($username); } } ?> Error image. Error

Heroku deploy failed: [remote rejected] master -> master (pre-receive hook declined): error: failed to push some refs

廉价感情. 提交于 2019-12-19 10:44:16
问题 I copied an existing app into a new repository. It works locally. Deploys work for the original. I'm using PHP, Yii, and Composer. I don't know what fxp/composer-asset-plugin is. C:\Users\Chloe\workspace\affiliorama>git push heroku master Counting objects: 699, done. Delta compression using up to 8 threads. Compressing objects: 100% (655/655), done. Writing objects: 100% (699/699), 25.36 MiB | 142.00 KiB/s, done. Total 699 (delta 146), reused 0 (delta 0) remote: Compressing source files...

yii2 gridview toggle column

被刻印的时光 ゝ 提交于 2019-12-19 10:18:09
问题 I am new to yii2. and learning it slowly. I am using yii2 gridview in my project I want to show hide columns dynamically. requires something like this [https://datatables.net/examples/api/show_hide.html =>demo is given in this link] but cant understand how to do this? can anybody help? code=> <?php $gridColumns = [ ['class' => 'yii\grid\SerialColumn'], ['class' => 'yii\grid\CheckboxColumn'], [ 'header' => '<input type="checkbox"> Name',//onclick of this checkbox show / hide the column

Yii2 QueryBuilder Update with Join

强颜欢笑 提交于 2019-12-19 07:52:11
问题 I have the following raw SQL query: UPDATE `pay_audit` JOIN `invoice_items` ON `invoice_items`.`mdn` = `pay_audit`.`account_id` AND `invoice_items`.`unitprice` = `pay_audit`.`payment` AND `invoice_items`.`producttype_name` LIKE 'PAYMENT' AND DATE_FORMAT(`invoice_items`.`created`, '%Y-%m-%d') = '2015-02-21' SET `pay_audit`.`invoice_item_id` = `invoice_items`.`id` WHERE `pay_audit`.`report_date` = '2015-02-21' The date is a variable $date in php. How can i "convert" this raw SQL query into Yii2

How to set default schema in Yii2

你离开我真会死。 提交于 2019-12-19 05:23:54
问题 My Yii2 is setup with PostgreSQL. Instead of using separate database per project, I like to use schema for each project. Problem with later setup is that I can't figure out how to select default schema "defaultSchema" through configuration. I am having a problem with migrations table because it defaults to "public" schema when I run migration command. Default "public" schema also prevents using database user's search_path. Although I set up my db user with "search_path=myschema, public" I

How do I pass a global variable in Main layout page before $content in Yii2

谁说我不能喝 提交于 2019-12-19 04:14:07
问题 I am trying to create dynamic menu in yii2 using "Nav::widget". Here is my code in menu section in main layout page: echo Nav::widget([ 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], Trying to get the solution: Please have a look:: 1 I have created a super controller "components/Controller.php" in app: namespace app\components; use app\models\MenuPanal; class Controller extends