Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined Index: value #91

Open
alekmlynek opened this issue May 19, 2021 · 1 comment
Open

Undefined Index: value #91

alekmlynek opened this issue May 19, 2021 · 1 comment

Comments

@alekmlynek
Copy link

alekmlynek commented May 19, 2021

When using this with a one-to-one relationship, Nova throws an error "Undefined index: value".

Full error:
Undefined index: values {"userId":2,"exception":"[object] (ErrorException(code: 0): Undefined index: values at /var/www/vendor/kirschbaum-development/nova-inline-relationship/src/NovaInlineRelationship.php:520)

public function fields(Request $request)
     {
       return [
         ID::make(__('ID'), 'id')->sortable(),
         HasOne::make('Delivery Options', 'deliveryOption', ShippingZoneDeliveryOption::class)->inline(),

If I take out "inline" the relationship works. I can create, update and do all the regular things. As a matter of fact, if I create the relationship traditionally and then enable inline on it, I can update it normally.

The issue seems to be with creating it. I'm using the latest Nova/Laravel version.

-- Edit --
When I trace the code NovaInlineRelationship.php:520, it seems like $itemData only has a 'modelId' property, but no values, so an error is being thrown.

▾ $itemData = (array [1])
|    ⬦ $itemData["modelId"] = (string [1]) `0`
@alekmlynek
Copy link
Author

Ok, I resolved the issue. I was using a "heading" field, which has no form value (It is a label). This module does not support this, and throws the error.

Unsure the best way to fix this. Potentially guarding if values are set before trying to use them, essentially omitting fields that don't need to be processed.

I don't see this as an urgent issue. Current work-around is not to use helper fields like markup/heading. Fix would be nice to keep large inline relationships user friendly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant