here i want to select Airline from a list this is the code: Answer <?= $form->field($model, ‘some_column’)->dropdownList([‘1’ => ‘aaa’, ‘2’ => ‘bbb’], [‘prompt’ => ‘—Select Data—‘]) ?> here is yii2 dropdown’s simplest view
Tag: yii2
Is there a way to make a sidebar with the default Bootstrap 4 widget Yii2
I want to know if there is a way to make a sidebar with Bootstrap 4 default NavBar widget Answer https://github.com/kartik-v/yii2-widget-sidenav Helped me for this one, realy usefull.
yii2: how to set Access-Control-Allow-Origin header
I have this yii2 controller where I want to set Access-Control-Allow-Origin: * header Please Help! Answer I have solved it by updating the behaviors() function
Excel file cannot be read by arrays in php
Sorry for my english) I have a problem! I read file with extension .csv but each line returns string, like this I can’t convert these strings to array. This is my code. This is my file. Thank you for your help))) Answer You ask no question actually… But the CSV is quoted properly, at least if the double quotes ought
Validating data in a stored JSON file in the DB using YII framework
I am trying to write a rule in my Yii project to add an exempt rule when we have a data point collected on a stored JSON. The following is my sample Yii script for the validation rule In my database, I have a column where I store extra variables as a stored JSON as shown in the diagram below,
What is the best way to do the job of Group By in mysql when sql_mode=only_full_group_by
I want to perform a query like to get the last record of any type in DB, at my localhost, I use Maria Db and the query is as follow: group is a column which I save type in it, for instance: marketing, blog, order, etc This query works fine on local, but on the server I get the following
How make a many-to-many rest API in yii2
I’m trying to get a many-to-may relationship to work, but I can’t get it to work. I have a database with 3 tables: users, favorites & videos. The favorites table contains 2 foreign keys that point to the users table and the videos table. Currently I have the following: User Model: Video Model: VideoController: (ActiveController) Following what they did in:
Yii2 select2 database exception number of bound variables does not match number of tokens
when i use select2 widget in my yii 2 applicaton, it will cause the following error: The executed sql does not apply my override in find function of Page model as follow: Debug stack hint me to beforeInsert() function in ActiveRecord at line 333 & this code: Every thing seems ok, so whats wrong? Answer I had a same problem,
How to handle error from controller using PJAX in YII2?
I am using Yii2 Pjax widget which is unable to throw error from controller due to which I am unable to log error for users when there is any error coming from the controller. PJAX code CONTROLLER code: I have tried below clientOptions but not working Also used javascript but no help :- Is there any way from which I
Yii2, how to add a LIMIT on a leftjoin to get only 1 result back
I am trying to get all records from the product table, these records are unique but i use a leftjoin to add a second table with images of these products but when I do it will return some products more than once as some products have 1 or more images. How can I use a limit on the product_images table