Skip to content

Can I get the form instance index (within a collection) in the form class? #121

Answered by lsmoker
lsmoker asked this question in Q&A
Discussion options

You must be logged in to vote

Here's how I got the sibling ID in the OpportunityForm and then updated the show_condition for each Bundle sibling:

    # the "X" will be replaced below (in get_context) with the bundle sibling id
    # within the CreditReportCollection
    show_condition = 'bundles.X.collapse_opp.toggle'

    def get_context(self):
        context = super().get_context()
        # see show_condition assignment above
        bundle_id = self.form_id.split('.')[1]
        context['show_condition'] = context['show_condition'].replace("X", bundle_id)
        return context

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jrief
Comment options

Comment options

You must be logged in to vote
1 reply
@jrief
Comment options

Comment options

You must be logged in to vote
1 reply
@lsmoker
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by lsmoker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants