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

Feature/issue 154 attach components to incidents on create #158

Conversation

AlexJump24
Copy link
Contributor

See #154

image

Components can be added on the the create flow, ideally would have utilised the relation manager but this is not possible in Filament on create.

I have therefore took this approach https://filamentphp.com/docs/3.x/forms/fields/repeater#integrating-with-a-belongstomany-eloquent-relationship which also required me to add the table name on the model as it was picking it up wrong.

Annoyingly I've been unable to support multiple select like on the edit flow though with this approach, hopefully this is ok for now!

@jbrooksuk
Copy link
Member

@AlexJump24 awesome, thanks! I wonder if this could be combined with a repeater field and mutated data to specify the status? https://filamentphp.com/docs/3.x/forms/fields/repeater/

@AlexJump24
Copy link
Contributor Author

@jbrooksuk sorry this is already a repeater field to add multiple components and their status (which I cut off the screenshot) unless you mean for something else.

@jbrooksuk
Copy link
Member

@AlexJump24 ah, I see. Sorry for the confusion, I didn't have my laptop on me at the time. I see what you mean now; you're unable to select multiple components and assign one status in one go.

This is a trade off for now. Maybe @danharrin has some advice 🤞

@jbrooksuk jbrooksuk merged commit 2391521 into cachethq:main Dec 30, 2024
16 checks passed
@danharrin
Copy link

If you wanted to select multiple components and assign them all the same status, replace the repeater with a BelongsToMany multiselect, and pass a function to pivotData() to $get() the value of the status to attach with.

If you wanted multiple groups of components with different statuses, you would need the multiselect inside the repeater, and then after relationship() chain saveRelationshipsUsing(), which accepts $record (Incident) and the $state to save to the incident (attach the components). However, I think doing this would be confusing to users since they might not understand the difference between creating new repeater items for components or selecting multiple in the multisleect.

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

Successfully merging this pull request may close these issues.

3 participants