Jump to content

Error when submitting pireps


Vetrro
 Share

Recommended Posts

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 

f13b985e21191a2c337e507e2e00f12b.png

 

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 by Vetrro
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

d406199787f449479ffb946eb4a01bfc.png

ff0f3b547d6055323ea9fda425a7060f.png

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 :P 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...