Questions tagged [yii2-model]

Use this tag if your question relates to the Yii2-model-class or one of its descendants.

This tag should be used whenever your question relates to the \yii\base\Model class or one of its descendants like \yii\db\ActiveRecord.

320 questions
0
votes
0 answers

I want to update form with clone values in yii2

In update from, I am using values of two models with clone fields, in models variable, there are values but from not showing. this error is showing PHP Fatal Error – yii\base\ErrorException Call to a member function isAttributeRequired() on array…
Priya
  • 1
  • 1
  • 4
0
votes
0 answers

Issue with Yii2 ActiveQuery

When I try to run the query mentioned below, I get this error - strtoupper() expects parameter 1 to be string, array given (/vendor/yiisoft/yii2/db/QueryBuilder.php - Line 1050) $bookings = \app\models\Bookings::find() ->where([ 'AND', …
eth.block
  • 512
  • 1
  • 5
  • 17
0
votes
1 answer

Sum on the multiple relations between models

I have 3 models modelOne ( relation one to many ) modelTwo ( relation one to many ) model Three In the third model there are columns with numbers, and I have created relation between second and third model to sum columns. Like this... public…
tigrasti
  • 342
  • 3
  • 15
0
votes
1 answer

validation is not working after setting scenario

my client side validation is not working after creating scenarios. it works fine before creating scenario . i have two scenarios update and create, i've two field to be required on create scenario and i've one field to be required on update…
Ajith Lal
  • 83
  • 2
  • 9
0
votes
2 answers

yii2 Filtering grid with dropdown list from same model

I am using the following functions in my Contact model public static function getParents() { return $this->hasMany(Contact::className(), ['parent_id' => 'id']); } I want to get the return of this array in the filter attribute of my view: …
open-ecommerce.org
  • 1,763
  • 1
  • 25
  • 41
0
votes
1 answer

Yii2 model search between query

I Want to impliment below mysql query in yii2 model search() SELECT * FROM `parking_availability` WHERE ('09:00' BETWEEN `time_start` AND `time_end` ) AND ( '11:00' BETWEEN `time_start` AND `time_end` ) I have applied like this …
Biju s
  • 420
  • 1
  • 7
  • 16
0
votes
3 answers

Yii2 query for posts in a space

I had a DB with a post table, a content table, and a space table. A post is a type of content, and a space is a container for many posts. I want to get all posts within a space. Post: id object_id -------------- 1 22 Content (object_id -->…
lilbiscuit
  • 2,109
  • 6
  • 32
  • 53
0
votes
1 answer

Yii2 query for users in group

I had a DB that had a user table and a group table and the group table had a column user_id which made it simply to return a list of users in a group: $users = User::find() ->where(['{{user}}.group_id' => $group_id]) ->all(); Now the user_id…
lilbiscuit
  • 2,109
  • 6
  • 32
  • 53
0
votes
0 answers

Yii2 ActiveRecord add a new record with unique text field

I am using Yii2 and ActiveRecord. I have a field called "code" and for each record, it is meant to have a unique value like this: "REC0001", "REC0002", "REC0003" in a sequencial manner. All works and I can generate a record code as described.…
Mihai Pop
  • 65
  • 6
0
votes
2 answers

Data is not storing in the database in yii2

I have two models in my project Employee visa model and visa track model.I want to store the primary key of employee visa table(ie.,employee_visa_id) in employee_visa_id field of the next table visa track. The roles of visa track is: public function…
Dijo
  • 73
  • 2
  • 10
0
votes
3 answers

Kartik GridView Yii2 : Toggle data not working in toolbar

I am using Yii2 kartik gridview. Below are the 2 images before and after toggleData button is clicked. I am unable to see Full data in gridview. BEFORE AFTER Only the pagination goes away but gridview does not display all records. I have 10…
Ankur Soni
  • 5,725
  • 5
  • 50
  • 81
0
votes
2 answers

Not equal condition with findAll()

I am trying to pull record from a table using the following code $userId = Yii::$app->user->id; $lists = PromoLists::findAll(['user_id' => $userId, 'list_type' => 'custom']); which outputs a query like below select * from promo_lists where user_id…
Muhammad Omer Aslam
  • 22,976
  • 9
  • 42
  • 68
0
votes
1 answer

Joining Multiple tables in GridView

I am using yii2 framework and trying to join multiple tables. I have managed to join 3 tables together but i am not clear how to extend this to 4 tables. I joined three tables as follows >>> //In Tasks Model public function getLocation() { …
Richard perris
  • 511
  • 1
  • 6
  • 15
0
votes
1 answer

yii2 How to get correct URL from table

I have created a dynamic nav bar menu, but can't get the correct URL with a parameter. Here's part of my model code: public function getNavMenu($menu_id) { $menu = Menus::find($menu_id) ->where('menu_id = :menu_id', [':menu_id' =>…
sudo_ee_
  • 109
  • 5
  • 15
0
votes
2 answers

PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'Model Name' not found

I trying migration my project from yii1 to yii2. I have some model function I make when I still use Yii1, is among others is generate id uniq function's, like this: public static function generateID($tableName, $modelName) { $dateNow =…