Dependent Dropdown in Yii2 making values reset while updating the Active form

前端 未结 1 565
孤街浪徒
孤街浪徒 2021-01-17 06:17

Here my problem is i have a form . In that i have dependent dropdown. for example if i select company name it automatically selects the dependent company email and company p

相关标签:
1条回答
  • 2021-01-17 06:47

    Finally i found answer, actually mistake was mine, because here am using getting records based on company_id but here i have used approvaldetails table id so that is the mistake, after i changed it to company_id, now its working good

    public function actionLists2($id)
        {
    
            $countEmployeedetails = Employeedetails::find()
                    ->where(['company_id' => $id])
                    ->count();
    
    
            $employeedetails = Employeedetails::find()
                    ->where(['company_id' => $id])
                    ->all();
    
            if($countEmployeedetails >= 0)
            {
                foreach($employeedetails as $employee)
                {
                    // $arr["id"] . '-' . $arr['designation']
                        echo "<option value='".$employee->id. '-' .$employee->name. "'>".$employee->RelationName."</option>";
                }
            }
            else{
                echo "<option>-</option>";
            }
    
        }
    
    0 讨论(0)
提交回复
热议问题