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
0
votes
2 answers

Yii2 model custom rules and validations for attribute which is array

Being trying to sort this out but going nowhere with it. I have got an array as attribute for a model and I am trying to create custom validation for some of the keys in the array as required. Or even can't figure out how the attribute labels will…
Think Different
  • 2,785
  • 1
  • 10
  • 18
-1
votes
1 answer

3 Different tables have same Foreign Key, How to select

Supposed I have 3 different tables which have identical Foreign Key like below:- Table One product_unit | id | product_id | weight | status_id | |:----|--------------|---------|------------:| | 1 | 4 | 300 | 1 | | …
-1
votes
6 answers

I want to get the backend url from frontend without using hardcoded URLs yii2

'urlManagerBackend' => [ 'class' => 'yii\web\urlManager', 'baseUrl' => 'http://backend.test', 'enablePrettyUrl' => true, 'showScriptName' => true, ], then I want to display the image saved under uploads…
-1
votes
1 answer

YII2 - Save user ID to work with it on other pages

I'm building a questionnaire site. On this site the user enters his email to receive the result of his questionnaire. So this site has no authentication. How do I store the user's email to the end of the questionnaire? It is my User…
Hamed
  • 158
  • 12
-1
votes
1 answer

Get model by table name in yii2

I have one method in several models, implemented in different ways. I only know the name of table in database. I must find model of this table. How to do? interface BaseIndexedModel { public function writeSometext(); } and some models…
Mary
  • 41
  • 7
-1
votes
1 answer

Yii2 not save many-to-many with new item

There is this code: $new_city = $request->post("new_city_select"); $city = City::find() //find item by name ->where(['=', 'name', $new_city]) ->one();; if ($city == null) { …
kome
  • 1
  • 2
  • 4
-1
votes
2 answers

Yii2 Trying to get property of non-object error with listView relational model

I have two tables. students(id,email,password,f_name,l_name,unique_id,create_date,last_update) comments(id,ad_id,commented_user,comment,create_date,last_update) table relation -> comments.commented_user = students.email comments class class…
-1
votes
1 answer

Yii2: joinWith andFilterWhere with find_in_set

I am trying to convert an SQL query like this select t1.id,t1.form,t1.type, group_concat(t2.department) as departments from appraisal t1 join department t2 on find_in_set(t2.id,t1.dept) group by t1.id into yii2 AppraisalSearch model. I tried…
user7282
  • 5,146
  • 8
  • 38
  • 67
-1
votes
1 answer

How to check if submitbutton detect click

Hello Please I try learn this tutorial Yii2 tutorial 3 But not working, when I click on submit button not change... if edit it's empty or not... I thing so 'btn btn-success']); ?> not detect click, how…
trip07
  • 157
  • 1
  • 7
-1
votes
3 answers

Create multiple logins in the same browser at same time

I want to create multiple logins at a time on the same browser, like admin and user. For that we are using different models like LoginForm.php and Adminlogin.php and different identity classes, i.e. User.php and Admin.php. But when we login with…
Renu Thakur
  • 495
  • 9
  • 30
-1
votes
2 answers

Get Category names from category_master table in another model's view

I have two different tables: document_master doc_id cat_id doc_name category_master cat_id cat_name cat_desc I want cat_name in dropdown of view file document model. I have created model called catmodel which contains details of…
vijay nathji
  • 1,490
  • 11
  • 22
-1
votes
2 answers

Getting related records only in yii2

Assume this schema: category(id, name) article(id, categoryId, writerId, title, content) writer(id, name, age, location) I want to be able to get all articles written by a specific writer if i am starting at the category level. That is category >…
user2707590
  • 836
  • 10
  • 26
-2
votes
1 answer

How to make search filters work with formatted dates in Yii2?

$query->andFilterWhere(['like', 'date_of_birth', date('d-m-Y',strtotime($this->date_of_birth))]); It's not working..
-2
votes
1 answer

How to add orderBy() with where() of Find()?

How to add an orderBy() with a where condition? $floor_data = Floors::find()->where(['building_id' => $id])->orderBy->(['floor_no' => SORT_DESC])->all(); This is giving me a syntax error saying syntax error, unexpected '(', expecting identifier…
Sarath C
  • 13
  • 3
-2
votes
1 answer

how to keep selected value on Yii2 html::dropddownlist?

i have the following code in my view: all(),'region','region'),[ 'prompt' => 'Select Region..','style'=>'width:200px',]) ?> and submit button
1 2 3
20
21