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

Method to send data to get_item #50

Open
Billybob opened this issue Sep 28, 2023 · 0 comments
Open

Method to send data to get_item #50

Billybob opened this issue Sep 28, 2023 · 0 comments

Comments

@Billybob
Copy link

Hi,
an example of how to send member_choices to get_item?

forms

@property
def member_choices(self):
    """ return all members of the specific team """
    members = self.team.team_users.all()

    return members

@staticmethod
def get_items(search=None, values=None):
    items = None
    if search is not None:
        items = list(filter(lambda x: x.get("value") in values, data))

    return [{"label": x.label, "value": x.id} for x in items]

to = forms.CharField(
    widget=widgets.Autocomplete(
        name="to",
        options=dict(
            multiselect=True,
            get_items=get_items,
            minimum_search_length=0,
        ),
    )
)

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