yii2

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-

Yii2 RESTful relational data

天涯浪子 提交于 2019-12-14 04:23:33
问题 I am having some trouble getting the Yii2 RESTful API returning relational data. I have this working when viewed through the frontend but i am trying to get the same data through the API and its not working the same way. Tables country - PK is population_id population - Foreign Key is country.population_id I am getting this error: { "success": false, "data": { "name": "Invalid Configuration", "message": "The \"query\" property must be an instance of a class that implements the QueryInterface

yii2 migration command gives warning how to fix it?

╄→гoц情女王★ 提交于 2019-12-14 04:14:39
问题 I want to download and use thyseus/yii2-message. followed steps on github. for installation 1) $ composer require thyseus/yii2-message 2) $ php yii migrate/up --migrationPath=@vendor/thyseus/yii2-message/migrations warning PHP Warning: Module 'openssl' already loaded in Unknown on line 0 Warning: Module 'openssl' already loaded in Unknown on line 0 Exception 'yii\base\InvalidConfigException' with message 'The configuration for the "user" component must contain a "class" element.' in C:\xampp

yii2 get name instead of id

血红的双手。 提交于 2019-12-14 03:59:53
问题 hi i have this weird problem. i had a table relation. and i want to view the related table field name instead of id. here is my model: public function getQCat() { return $this->hasOne(QbCategory::className(), ['id' => 'q_cat']); } here is my view: <?php echo DetailView::widget([ 'model' => $model, 'attributes' => [ 'q_cat', 'question:ntext', 'q_c1:ntext', 'q_c2:ntext', 'q_c3:ntext', 'q_c4:ntext', 'q_ans:ntext', ], ]) ?> that 'q_cat' field in view i want to display name instead of id. i tried

Yii2 migrations. Percentage sign and brackets in table name

一曲冷凌霜 提交于 2019-12-14 03:58:02
问题 I browsed the yii2-oauth2-server code on github and encountered interesting syntax in the migration file. The code in question looks like this: $this->createTable('{{%oauth_clients}}', [ ... ], $tableOptions); Can someone explain the {{%oauth_clients}} part? What does it mean when the table name is enclosed in {{%..}} ? The official documentation on migrations says nothing about it and all examples have the "raw" table names like this: $this->createTable('post_tag', [ ... ]); I checked my

Yii2: dynamic model attributes

自古美人都是妖i 提交于 2019-12-14 03:57:26
问题 I have table Lang: id | lang_name Table2: Messages: id | message_code Table3: Dictionary id | message_id | lang_id | translation I want to bring to the gridview with languages. Format: message_code | en_translation | ..._translation |..._translation As the number of languages is not known, i pass value of columns in array to gridview. There is one problem: I need to pass the value of the language id to relation model. I do not know how. $searchModel = new langmessages_search(); $dataProvider

js active form validation in yii2

六眼飞鱼酱① 提交于 2019-12-14 03:29:46
问题 I have a active form and I am trying to validate it using the script written below : jQuery("#form").yiiActiveForm("submitForm"); The problem is, the script always returns false. But when I call it second time with some delay, it returns true. jQuery("#form").yiiActiveForm("submitForm"); setTimeout(function () { if (jQuery("#form").yiiActiveForm("submitForm")) { //ajax call... } }, 300); My question is, how does validation works in yii2 ? And is there a better way to validate active forms in

Conditional Validation In Yii2.0 fail

无人久伴 提交于 2019-12-14 03:26:29
问题 I'm setting up the required rule based on condition but looks like it abuse the condition. what I am I went wrong ??? ['objective_id','required','when'=>function($model){ return $model->subcategory_id == 3; }], 回答1: I figure out my problem, the code is right but I forgot that I'm working with ActiveRecord. I solved it by set up the field "objective_id" to null in a database table 来源: https://stackoverflow.com/questions/54228799/conditional-validation-in-yii2-0-fail

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