Inline select of a related entity field
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.
Thanks for the suggestion @andypooletrioteca.
Feel free to issue a PR for this addition. Thanks!
@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);
}
}