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

Use of LiveupdateBoolean in a Nova resource breaks dedicated form #2

Open
rkok opened this issue Oct 6, 2021 · 0 comments
Open

Use of LiveupdateBoolean in a Nova resource breaks dedicated form #2

rkok opened this issue Oct 6, 2021 · 0 comments

Comments

@rkok
Copy link

rkok commented Oct 6, 2021

Hi, first off, thanks for this nice little module.

There seems to be an issue where the checkbox field works correctly in table views of a resource:

Screenshot at 2021-10-06 14-40-48

...but breaks the dedicated form for that resource: (form cannot be submitted due to a JS error)

Screenshot at 2021-10-06 14-41-17

We have found the following workaround for the issue:

// Answer.php
class Answer extends Resource
{
    // ...
    public function fields(Request $request)
    {
        return [
            // ...
            (strpos($request->fullUrl(), '/answers/') !== false
                // Use plain checkbox in the dedicated form
                ? Boolean::make('Correct answer?', 'correct_answer')->hideFromDetail(true)
                // Use inline checkbox in table view
                : LiveupdateBoolean::make('Correct answer?', 'correct_answer')->hideFromDetail(true)),
        ];
    }

Is there a better way to do this?

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