Vetrro Posted July 12, 2021 Report Share Posted July 12, 2021 (edited) PHP Version: 7.4.21 phpVMS Version: 7.0.0-dev+210620.cde6fb MariaDB Version: 10.3.29 Whenever a pirep is submitted it throws out this error: "Trying to get property 'name' of non-object {"userId":1,"exception":"[object] (ErrorException(code: 0): Trying to get property 'name' of non-object at /phpvms/app/Services/PirepService.php:577)" and I'm not to sure how to go about fixing it so any help would be great Thanks. also included an image of where the error is occurring if that helps Edit: Also some further information regarding this, When the pirep is summited it still goes through to the admin panel for viewing/approving but when the actual submission is done it brings up a 500 server error page for the user submitting it. Edited July 12, 2021 by Vetrro Quote Link to comment Share on other sites More sharing options...
DisposableHero Posted July 13, 2021 Report Share Posted July 13, 2021 On 7/12/2021 at 2:32 PM, Vetrro said: Whenever a pirep is submitted it throws out this error: "Trying to get property 'name' of non-object" That line belongs to the code part of "custom" pirep fields which are defined by the va admin (probably by you). /** * Update any custom PIREP fields * * @param string $pirep_id * @param PirepFieldValue[] $field_values */ public function updateCustomFields(string $pirep_id, array $field_values): void { if (!$field_values || empty($field_values)) { return; } foreach ($field_values as $fv) { PirepFieldValue::updateOrCreate( ['pirep_id' => $pirep_id, 'name' => $fv->name], // This is line 577 your error refers ['value' => $fv->value, 'source' => $fv->source] ); } } What that errors says is this "You want me to use the name of a custom field, but I can not find the that custom field itself" I would suggest checking your custom fields defined for pireps first. 1 Quote Link to comment Share on other sites More sharing options...
Vetrro Posted July 13, 2021 Author Report Share Posted July 13, 2021 We have a custom field in the pirep area and if I remove the field pireps file fine again but I would like to keep the field if I could. I tried re-adding the field after deleting it and it still has the issue. So by the error saying it cant find the custom field is that meaning It cant find it on the pirep creation page? Or does it mean that it cant find some other way. Sorry if I'm frustrating to answer but I'm not too good with code stuff as of yet lol As for the custom field it is showing up on the pirep creation page as a field and can be filled out. I've included images of what I mean not sure if it is any help at all though shows the field that is created in the admin panel and then the field showing up on the pirep creation page. Thanks for the reply at least I understand what's causing the issue now I just still don't know how to get a fix in. Quote Link to comment Share on other sites More sharing options...
DisposableHero Posted July 16, 2021 Report Share Posted July 16, 2021 On 7/13/2021 at 11:35 PM, Vetrro said: We have a custom field in the pirep area and if I remove the field pireps file fine again but I would like to keep the field if I could. I tried re-adding the field after deleting it and it still has the issue. So by the error saying it cant find the custom field is that meaning It cant find it on the pirep creation page? Or does it mean that it cant find some other way. Sorry if I'm frustrating to answer but I'm not too good with code stuff as of yet lol As for the custom field it is showing up on the pirep creation page as a field and can be filled out. I've included images of what I mean not sure if it is any help at all though shows the field that is created in the admin panel and then the field showing up on the pirep creation page. Thanks for the reply at least I understand what's causing the issue now I just still don't know how to get a fix in. Sorry for the late reply, I totally forgot this message Can you please change that fields name to CI or CostIndex (no spaces between Cost and Index) and try, the error may be related to the space being used in the name. If this does not help, we may look further. Quote Link to comment Share on other sites More sharing options...
Vetrro Posted July 16, 2021 Author Report Share Posted July 16, 2021 Renaming to CI did not work, and no problem on taking awhile to reply its not really that big of a deal since most of our VA uses ACARS but I would like to have no errors on the site and this is the only one we have atm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.