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.

304 questions
3
votes
4 answers

How to manage password during update user profile in Yii2

I can add user successfully, For Password hashing I am using md5() But when I update user it is giving an error. Here are the model rules: public function rules() { return [ [['firstname', 'lastname', 'username', 'email', 'role',…
user2678776
3
votes
1 answer

Yii2. Many inputs for one Model/DB field

How such inputs could be translated into DATE field in DB? Customer insisted on such way to input user birthdate. First my thought was simply to concat in one field in beforeValidate, but after this inputs won't be able to display date, that was…
D.R.
  • 1,676
  • 2
  • 16
  • 37
3
votes
3 answers

Yii2 different form fields on create and on update scenario

In my Model I have created different scenarios. I have one form which is rendered bu both create and update method. The form fields are as follows Form.php errorSummary($model, $options =…
Mohan Prasad
  • 572
  • 8
  • 30
3
votes
1 answer

Yii2 grid view filter sql

Hi every one I have a grid view with SQLDataProvider and I'm doing the ModelSearch. Every tutorial on internet are with ActiveDataProvider and I don't want to use ActiveRecord because of the way I'm using my database. So my question is : how can I…
Samaël Villette
  • 198
  • 1
  • 22
3
votes
3 answers

How to create a directory inside a directory in yii2 and upload file into that directory

I have a form ['enctype' => 'multipart/form-data']]); ?> field($userformmodel, 'user_image')->fileInput(); ?> 'btn btn-primary']) ?> …
3
votes
1 answer

How to partition table on Yii2?

A table named demo,now need to partition it just like demo1,demo2,demo3,....,demo10 So how to partition the table on Yii2? I probably known should add a method getTableName in Model.
tanteng
  • 499
  • 1
  • 5
  • 10
3
votes
2 answers

yii2 get activerecords by relation column

I need to select ActiveRecord's that have related AR's with specific column value. Situation: 'User' may have many 'Branches' - via junction table, and Branch is related to Department. I have department_id, and I want to select Users, that have…
Ixon
  • 63
  • 4
3
votes
1 answer

Yii2 activerecord unexpected results with limit in with() callback function

I'm having a problem building a query with Yii2. Let's say we have four related models: Customer, Order, Orderitem and Orderitempicture. Order is related to Customer, Orderitem is related to Order, and Orderitempicture is related to Orderitem. Below…
Rayan Salhab
  • 111
  • 6
3
votes
5 answers

Convert Yii to Yii 2.0: getRestParams()

How to write this line of code from Yii to Yii 2.0: Yii::app()->getRequest()->getRestParams() ?
delux
  • 1,154
  • 5
  • 18
  • 40
3
votes
1 answer

Yii 2.0: Sorting on column in a GridView

$dataProvider = new ActiveDataProvider([ 'query' => UserProfile::find()->joinWith(['user'])->where(['<>', 'user.status', 0]), 'sort' => ['attributes' => ['fullname', 'phone', …
2
votes
3 answers

Yii2 Gridview error

I want to display column from another table in gridview. In my controller actionIndex: public function actionIndex() { $user_id = \Yii::$app->user->identity->id; $queryFile = PowerGen::find(); $queryFile…
2
votes
1 answer

Yii 2.0 - Trying to get property of non-object

I try to change the "ID Kategori"(Category ID) to "Nama Kategori" (Category Name), the Category ID is in product table and has a relation to category table. for the gridView im using kartik-v gridView i know the error is at return…
2
votes
1 answer

How to add custom controller to extension in vender folder in yii2?

I have an extension yii2-admin for RBAC, and I would like to add to this extension another controllers, views, models etc. Because in this module I would like to keep all operations who admin like CRUD for User table and for another. What is the…
2
votes
0 answers

Yii2 model save returns true but there is no change in MySQL

Actually, If I update my model in the action of controller(in this case it is actionTest) it gets updated. Here is my code: public function actionTest() …
Yusuf
  • 31
  • 3
2
votes
1 answer

Yii2 - Updating single field of another model from update form

Longtime passive user of StackExchange and I am at a loss here. It's probably super simple, but I'm stuck. I've used gii-enhanced to build the models and CRUD. I have two models: ordenes and facturas. When I'm updating a facturas model I can link…
1 2
3
20 21