yii2-advanced-app

how to keep selected value on Yii2 html::dropddownlist?

老子叫甜甜 提交于 2019-12-20 07:48:42
问题 i have the following code in my view: <?=Html::dropdownList('region',null, ArrayHelper::map(Ethioregion::find()->all(),'region','region'),[ 'prompt' => 'Select Region..','style'=>'width:200px',]) ?> and submit button <?= Html::submitButton('Search', ['name' => 'dele','class' => 'btn btn-primary']) ?> my code working well but I have one big problem. I select a region and click the search button, the result comes correctly, and 10 result is shown per page when I click the next page, it gives me

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'],

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 upload files in root folder in yii2 advanced template?

混江龙づ霸主 提交于 2019-12-18 04:23:32
问题 I am unable to upload files in root folder. I uploaded files in root folder and access these files in frontend and backend application. 回答1: When using the advanced template you need to decide on a common place to store your files that can be accessed by both the frontend and backend application, additionally if you want the files to be publicly accessible via the web you need to insure this location is a public folder. I tend to use the frontend/web folder as my common upload location. When

Regarding GridView Filter in yii2

瘦欲@ 提交于 2019-12-16 18:02:13
问题 I have a table like this with 5 columns. TableName -Column1 -Column2 -Column3 -Column4 -Column5 I had merged them to display them in grid view as single column. Question How can i make filter condition query to search them based on user input.? Eg.User types something as input, it have search from all the 5 columns and return the result based on the search input.(Sorting works fine, please help me with filtering) If someone could helpme it would be great, Thanks. UPDATE: $query-

How to update dynamic field in yii2

送分小仙女□ 提交于 2019-12-14 03:20:56
问题 I want to create dynamic field with jquery without using any library. I have two filed in form but one filed label i want to create multiple time which is actually question option it can be more then one time. In below form.php you see that label field i create with jquery in multiple time. I can save them but i am not understand how i will show those filed which was more then one time in update case . Really sorry for my english. Controller public function actionCreate() { $model = new

Yii2 FileInput - Trying to get property of non object

佐手、 提交于 2019-12-14 02:43:47
问题 i am using Yii2 and Kartik's FileInput extension and I have successfully get the file uploads working(only single upload). My problem now is that, I get the error as in the title(with logs attached) if I did not choose any files(It should be optional). After much searching over the internet, I think it has to be something to do with array, but I am not sure how to fix that, especially even with the logs pointing to the exact line! Here is my log, Here is my model, namespace app\models; use

Remove index.php from url after removing web folder from frontend and backend in yii2

折月煮酒 提交于 2019-12-13 23:53:29
问题 I want to remove index.php from url. I put .htaccess in the root and wrote the following lines in common/config/main-local.php . But every url is redirected to backend. My .htaccess file: RewriteEngine on # If a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise forward it to index.php RewriteRule . index.php My common/config/main-local.php file: 'urlManager' => [ 'class' => 'yii\web\UrlManager', // Disable index.php

Yii2 : validate if at least one checkbox is selected

只谈情不闲聊 提交于 2019-12-13 18:24:46
问题 I have multiple Music releases for a user for which he wants to create a promo, on the promo create form we have all the releases listed and I am using a form model for creating the promo where I define all rules for my several inputs in the promo form model. I want to check if at-least one release is selected by the user when saving the form but it is not working as the checkboxes are created dynamically. my form code for that field foreach ($releaseInfo as $releases) { if (!is_null(

yii2:- how can i manage angularjs post request in yii2

江枫思渺然 提交于 2019-12-13 15:38:31
问题 I am trying to send post request from angular controller to yii front end controller. Here is my controller.js 'use strict'; define(['angular', 'd3', 'd3Cloud', 'services'], function (angular, d3) { /* Controllers */ return angular.module('oc.controllers', ['oc.services']) .controller('InitCtrl', ['$scope','$http', function ($scope,$http) { $scope.loginFun = function() { var formData = {username:$scope.txtUserName, pwd:$scope.txtPassword}; $http.post("http://localhost/yii2-angular-seed-master