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

How to save selected data from checkbox to database

My problem is when I select data from the check box and click save button, I do not know where it goes. Do I need to make another table or add column in events table. This is the coding for index.php for events.
Fyp16
  • 131
  • 1
  • 5
  • 16
1
vote
0 answers

yii2 select2 asset bundle not loading css when called from ajax

I am using kartik select2 library. I have the modal which is loading in the page from ajax with renderAjax. The modal has the select2 dropdown. The problem is it load the js but do not load the css files of select2. echo $form->field($assign_model,…
Ish
  • 2,085
  • 3
  • 21
  • 38
1
vote
0 answers

Yii2 How can I add a modal to display the view "actionView" in the ActionColumn of the gridview

How can do a modal with the actionView in show in index with the gridview Index: $dataProvider, 'pjax'=>true, 'columns' => [ ['class' =>…
Juam
  • 11
  • 3
1
vote
3 answers

Yii2 Converting model objects to array with ArrayHelper::toArray()

I am working in YII2 Framework on the following query SELECT T.id, T.name, T.status, IFNULL(T.image,'no-image.png') as DP FROM TABLE_NAME T; here is my code $modelTeam = Teams::find() ->select( ['T.id', 'T.name', 'T.status',…
Muhammad Omer Aslam
  • 22,976
  • 9
  • 42
  • 68
1
vote
1 answer

Whenever I add more than one row of data in my table, I get the error ''Getting unknown property"

I am very new to yii2. I have 3 tables task, activties and employees. Whenever I add more than one row of data in Activity table I get the following error - "Getting unknown property: backend\models\Employee::Employee_ID" My Activty model has…
user2211486
  • 237
  • 1
  • 6
  • 18
1
vote
1 answer

Uncaught RangeError: Maximum call stack size exceeded Yii2 popup form

I have a problem with a pop-up form in Yii2. "Update" is not working. The form is displayed but inspect tool shows: Uncaught RangeError: Maximum call stack size exceeded. The action of creating uses the same code and it works perfectly. I do not…
kamilZet
  • 13
  • 3
1
vote
1 answer

yii2 data to the db saves them all null

hello guys I have a problem when I send the form data in the database , all NULL fields are saved . Any suggestions? my Controller public function actionOffri() { $model = new Offri; if($model->load(Yii::$app->request->post())&&…
Saba
  • 115
  • 1
  • 15
1
vote
1 answer

Foreign key validation rule in Yii2

I have parent_id that can have NULL value - default sets to 0. Model ... [['parent_id'], 'integer'], [['parent_id'], 'default', 'value' => 0], [['parent_id'], 'exist', 'targetAttribute' => 'id', 'skipOnEmpty' => true], ... But exist rule didn't…
Marsick
  • 138
  • 1
  • 11
1
vote
1 answer

is it possible to upload a file in a model that inherits from ActiveRecord in yii2?

I generated a model with Gii from a database table in yii2.this model inherits from ActiveRecord . then I created a form from this model.now I want to upload a file with this form. is it possible to upload file with same model (that inherits from…
mojtaba.sln
  • 51
  • 1
  • 7
1
vote
1 answer

Yii2 display multiple images in gridview row

I want to display multiple images in a gridviews single row. For example: I have table A, Table B and table C. Table A has my_id. In Table B my_id is the foreign key. Along with my_id it has c_id. Table C has c_id which is in reference in Table…
Mohan Prasad
  • 682
  • 1
  • 9
  • 34
1
vote
2 answers

Yii2 passing an array in the FilterWhere Condition

I'm trying to pass array elements in the filter where condition. getFacilityID() function public function getFacilityID() { $facArray= array(); $facilityName = Facility::find()->where(['company_id' =>…
Mohan Prasad
  • 682
  • 1
  • 9
  • 34
1
vote
1 answer

Yii2 many-to-many model relation

I've implemented a many to many ralation between two yii2 models: slider, images, sliders_images where sliders_images is the junction table. Each model extend a basic model generated by Gii, so when i need i can overwrite the base model without lose…
MarBer
  • 535
  • 1
  • 5
  • 22
1
vote
2 answers

Yii2 in a form submission model is null after redirect

Upon form submission, if model is found in controller, a view is rendered with a set flash message but also with a customized message like hello username; ?> when applicable. Everything worked fine, until I decided I'd be fun to add…
Decimoseptimo
  • 103
  • 11
1
vote
1 answer

how to create search field in gridview without using search model

I have created sqlDataProvider in my controller and its working. My problem is i dont know how to provide search field since im not using the search model. this is code in my controller public function actionAnalisa() { $sql = "SELECT …
NoBody
  • 47
  • 2
  • 10
1
vote
3 answers

Yii2, find users that has active post

I have user and post table with oneToMany relation: In Post Model: public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); } And in User Model: public function getPosts() { return…
ingenious
  • 764
  • 2
  • 8
  • 24