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

Added ability to add relationships to TagsInput #14565

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

chrispage1
Copy link

@chrispage1 chrispage1 commented Oct 18, 2024

Description

This update adds the ability to create a TagsInput field that utilises a BelongsToMany relationship.

For example, a post relationship that has a ->tags() BelongsToMany relationship.

Example usage:

Filament\Forms\Components\TagsInput::make('tags')
    ->relationship(),

By default, it'll look for a BelongsToMany relationship based on the name value.

In its most basic form, if your BelongsToMany relationship matches the name you've given it (in this case 'tags') and the value column in your tags table is name, then there is no further configuration required.

However, if you need to, you can customise the relationship method and the label column that'll be used:

->relationship(relationship: 'testRelationship'), // change the method that'll be called on the model

->relationship(column: 'title'), // change the column that'll be plucked for the tag value.

->relationship('title', 'testRelationship'), // define both values

Visual changes

No visual changes

Functional changes

  • [ ✓ ] Code style has been fixed by running the composer cs command.
  • [ ✓ ] Changes have been tested to not break existing functionality.
  • [ ✓ ] Documentation is up-to-date.

@chrispage1 chrispage1 force-pushed the feature/tags-input-relationship branch from 6a94195 to 6359aeb Compare October 18, 2024 14:31
@chrispage1 chrispage1 force-pushed the feature/tags-input-relationship branch from 6359aeb to 65e16d2 Compare October 18, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant