2017-10-06 55 views
-3

我有一個bug,請告訴我,可能是什麼問題未定義指數:db_sub_form_move_to_topleft

類型:ErrorException 代碼:8 未定義指數:db_sub_form_move_to_topleft 線:113

這裏我的代碼:

23 public function index() { 
24 $company_id = Session_Helper::getSessionCompanyId(); 
25 $employee = Session_Helper::getSessionEmployee(); 
26 
27 //search company settings like approval process 
28 $company_profile = $this->dm->find(Company::class, $company_id); 
29 $company_settings_options = $company_profile->getSettings(); 
30 $enable_modules = []; 
31 $settings_view_data = []; 
32 if (!empty($company_settings_options)) { 
33  $enable_modules = $company_settings_options->getEnabledModuleIds(); 
34  $settings_view_data = $company_settings_options->getViewData(); 
35 } 


112 $data = [ 
113   'record_db_sub_form_move_to_topleft' => $settings_view_data['db_sub_form_move_to_topleft'], 
114   'record_db_sub_form_pending_bgcolor' => $settings_view_data['db_sub_form_pending_bgcolor'], 
115   'record_db_sub_form_backcolor' => $settings_view_data['db_sub_form_backcolor'], 
116   'record_employee' => $employee_count, 
117   'record_form' => $form_count, 
118   'record_submitted_form' => $submitted_form, 
119   'record_risk_assessment' => $risk_assessment_count, 
120   'record_form_group' => $form_group_count, 
121   'record_vehicle' => $vehicle_count, 
122   'reference_document_count' => $reference_document_count, 
123   'record_docket_count' => $docket_count, 
124   'chart_employee' => Dashboard_Statistics_Helper::getEmployeeCountByCompany($company_id), 
125   'chart_submissions' => Dashboard_Statistics_Helper::getSubmittedForms($company_id), 
126   'chart_route_plan' => in_array('enable_securatrak_tracking',$enable_modules) ? Dashboard_Statistics_Helper::getRoutePlanStatus($company_id) : null, 
127   'chart_completed_journey' => in_array('enable_securatrak_tracking',$enable_modules) ? Dashboard_Statistics_Helper::getCompletedJourney($company_id) : null 
     ]; 
+1

格式代碼正確地從開始[PHP的 –

+1

可能重複刪除的行號:「注意:未定義的變量「,」注意:未定義的索引「和」注意:未定義的偏移「](https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-通知-基金) –

回答

0

這意味着這個數組$ settings_view_data不包含你試圖獲得的密鑰。 所以我只好選擇:

1 - >檢查這項功能getViewData(),並確保它返回一個包含密鑰「db_sub_form_move_to_topleft」的數組。

2 - >檢查鑰匙「db_sub_form_move_to_topleft」得到它之前,並存在由用戶isset()函數是這樣的:

$data = [ 
'record_db_sub_form_move_to_topleft' => isset($settings_view_data['db_sub_form_move_to_topleft']) ? $settings_view_data['db_sub_form_move_to_topleft'] : '',