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

Inline select of a related entity field #27

Open
andypooletrioteca opened this issue Mar 23, 2020 · 2 comments
Open

Inline select of a related entity field #27

andypooletrioteca opened this issue Mar 23, 2020 · 2 comments

Comments

@andypooletrioteca
Copy link

I'm trying to use the component to update a related entity but i'm beginning to feel this is not possible.

Basically i'm trying to do something like this:

            InlineSelect::make('Status', 'relatedStuff.status')
                ->options(RelatedStuff::STATUS_NAMES)
                ->displayUsingLabels()->inlineOnIndex()->disableTwoStepOnIndex(),

The status list displays correctly but the value doesn't get updated when i change it.

Any guidelines on how to approach this development? i could try to do a pull request with this.

@brandonferens
Copy link
Member

Thanks for the suggestion @andypooletrioteca.

Feel free to issue a PR for this addition. Thanks!

@Paulsky
Copy link

Paulsky commented May 20, 2020

@andypooletrioteca Not sure if I understand you correctly. But I'm using the below workaround (I'm using Spatie's Status).

What I did is check in an Observer (Model::observe(ModelObserver::class)) in the updating event if the field is set, then update the related entity and unset the field. Like this:

InlineSelect::make('Status', 'inline_status')
                ->options(RelatedStuff::STATUS_NAMES)
                ->displayUsingLabels()->inlineOnIndex()->disableTwoStepOnIndex(),

In the Observer:

public function updating($model)
    {
        if(isset($model->inline_status)){
            $model->setStatus($model->inline_status);
            unset($model->inline_status);
        }
    }

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

No branches or pull requests

4 participants