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

Update fails on index and detail views with other required fields #1

Open
FabienFrays opened this issue Jun 12, 2019 · 7 comments
Open
Labels
bug Something isn't working

Comments

@FabienFrays
Copy link

Hi,
Thank's for your package.
The saving fails on index and detail views when the resource has any fields with a required rule.
Regards,
Fabien

@markrassamni
Copy link
Owner

markrassamni commented Jun 15, 2019

@FabienFrays Could you try doing this as a temporary workaround to see if it's fixed? I won't be able to look into the main issue for some time.

return [
    Text::make('column')
        ->rules('required')
        ->hideFromIndex(),

    Text::make('column')
        ->onlyOnIndex(),

    InlineBoolean::make('bool_column') 
        -> ...
];

If you could also please provide a code sample as I was not able to immediately reproduce your issue.

@markrassamni markrassamni added the bug Something isn't working label Jun 15, 2019
@FabienFrays
Copy link
Author

Ok thanks.

@mpanius
Copy link

mpanius commented Jun 19, 2019

I have the same issue, when using BelongsTo Field
hideFromIndex() didn't help

BelongsTo::make('Проект','project','App\Nova\Project')->withMeta([
                'belongsToId' => 1
            ])->readonly()->hideFromIndex(),
BelongsTo::make('Автор','user','\App\Nova\User')->withMeta([
                'belongsToId' => $this->user_id ?? auth()->user()->id
            ])->readonly()->hideFromIndex(),

@garrettjoecox
Copy link

garrettjoecox commented Sep 7, 2019

Found a workaround thanks to nova-inline-select

Add the following updateRules to all fields that are marked as required

Text::make('Email')
    ->rules('required', 'email')
    ->updateRules('sometimes'),

@kamilkozak
Copy link

kamilkozak commented Jan 12, 2020

I have the same issue, when using BelongsTo Field
hideFromIndex() didn't help

BelongsTo::make('Проект','project','App\Nova\Project')->withMeta([
                'belongsToId' => 1
            ])->readonly()->hideFromIndex(),
BelongsTo::make('Автор','user','\App\Nova\User')->withMeta([
                'belongsToId' => $this->user_id ?? auth()->user()->id
            ])->readonly()->hideFromIndex(),

Same issue here but using ->readonly()->hideFromIndex() works for me

@michapixel
Copy link

can confirm:

->updateRules('sometimes'),

does solve this issue for me. but it seems like an ugly solution to me.

@vesper8
Copy link

vesper8 commented Jan 14, 2021

For me just adding ->readonly() on BelongsTo fields made the 422 go away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants