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
1 answer

yii2 checkbox field dont'save data in db

i have a problem with the checkbox field that does not save me the data in the database . In the database I have the ' conditions ' field ( chekbox field ) as boolean . when sending the form I do not save as checked ( 1 ) . my model Rules…
Saba
  • 115
  • 1
  • 15
0
votes
1 answer

yii2 create forms in main.php layout how to spend the $model

Hello everyone I am a beginner in yii2 , I have to create a form in the footer at the main.php layout section. Default does not pass the model . Could you give me an exemplary of how to pass data in the form ? Thanks so much. Example of Controller…
Saba
  • 115
  • 1
  • 15
0
votes
2 answers

Yii2: Add/remove validation rules in Model from 3rd party module

In the main Yii2 application, how can we add validation rules to a Module (or an ActiveRecord) that comes with a 3rd party module? Can we modify existing rules? Say we have the following rule: ['currency', 'in', 'range' => ['USD', 'GBP',…
mae
  • 14,947
  • 8
  • 32
  • 47
0
votes
2 answers

yii2 user dektrium user_id

Hello guys i'm using yii2 user of dektrium . I would save user_id an account in my table. the User table has 1..N relationship with my table. I am a princiapiante and do not know how to save user id in my table. I tried so but the record in the…
Saba
  • 115
  • 1
  • 15
0
votes
1 answer

Unable to access yii2 active data povider from gridview

everyone this is my function that return the data provider to the gridview. public function search($params) { $query = EventOrganizer::find() ->where(['event.approve' => 0]) ->groupBy(['event.eventID']); //…
0
votes
1 answer

In yii2 How do we call through relations

For example there are A, B, C, D, E, F tables. A has a_id as foreign key in B. B has a_id and c_id as foreign key. C has d_id as foreign key. D has e_id as foreign key. Now how do I write a relation from A to D. As A has no direct relation to…
Mohan Prasad
  • 682
  • 1
  • 9
  • 34
0
votes
1 answer

Yii2 Relations to get a field using two foreign keys

I have issues to get a field from a table using two foreign keys. Explained the relations of the use tables below. User table hasMany Companies(company_id). Comapny table has company_id. Facilities hasOne Company_id(Based on the user…
Mohan Prasad
  • 682
  • 1
  • 9
  • 34
0
votes
1 answer

Yii2 class not found when moving application to live server

My application works perfectly locally however upon uploading to live server there's a couple of issues. The first one is I get the following error on one specific page of my application but not on other that user the same class. Class…
Connor Brough
  • 579
  • 1
  • 9
  • 24
0
votes
1 answer

Yii2 Customized Row's total in footer Kartik v ( display total of row values in footer)

I want to display total of row vaules in footer. I have tried several ways but doesn't show proper result. Any help will be highly appriciated. I am using kartik grid. I have tried this Yii2: Kartik Gridview sum of a column in footer but doesn't…
vijay nathji
  • 1,608
  • 13
  • 23
0
votes
1 answer

Yii2 foreach loop in grid-view displaying the same data

In my Yii2 I have tables and relationship setup. List of tables: User table -> foreign key is : company_id. Facility_table -> foreign key is : company_id. Area_table -> foreign key is : facility_id. productlinestable -> foreign key is :…
Mohan Prasad
  • 682
  • 1
  • 9
  • 34
0
votes
1 answer

Yii2 CSV text field to multiple select dropDownList

There is a database field called path it is text type and it is used to store paths marking strings as CSV, something like the following: *:*,site/about,site/* Originally, it is used as a text input field like the following:
SaidbakR
  • 13,303
  • 20
  • 101
  • 195
0
votes
1 answer

Yii2 single search box to search fields from two different tables

I have products table and productlines table. Product has relationship with the productlines. I want to have a single search box and search the fields from product table and fields from productlines table. My ProductSearch Model public function…
Mohan Prasad
  • 682
  • 1
  • 9
  • 34
0
votes
2 answers

Yii2: Configurable models inside module

What is the best practice of including models/activerecords within a Yii2 module in a way that they are configurable? These are just some of the problems we face when we want to use an activerecord included inside a module: Adding events &…
mae
  • 14,947
  • 8
  • 32
  • 47
0
votes
1 answer

Yii2 multiple models loop save error

I've a table in which I have to save multiple data, in my controller I've implemented this action: public function actionUpdateOrder($id){ /*DA TESTARE*/ //$result = 0; $result = true; $s = new Session; $model = new…
MarBer
  • 535
  • 1
  • 5
  • 22
0
votes
2 answers

Change one attribute value Yii2 REST API

I have created a REST API in Yii2 using ActiveController. The default implementation of actionIndex return all the models. What i want to do is to change the value of one attribute before sending response. for example i have image uploaded with…
Mushahid Hussain
  • 4,052
  • 11
  • 43
  • 62