I would like users to be able to select a context from a radio button question. How would I best approach this?

Thanks.

Comments

blisteringherb’s picture

You can create a form in a block with the names of the contexts you'd like users to be able to choose from, then call context_set() on submit. The trick is to get the context to be persistent. Not sure what criteria you need the context to be set on though. What sort of functionality are you trying to implement with setting the context with a form?

bgmmx4c’s picture

I am trying to give the user the ability to display different content by selecting a context. Currently the site triggers the context by role. But if a user wants to see the six different contexts he must register 6 times and select a different role for each registration.

Could the form set a role behind the scenes and trigger a persistent context?

blisteringherb’s picture

That sounds like it would work fine. You'd just have to make sure that they either only see that block if they haven't made a selection yet, or if you decide to allow them to switch contexts, the form would have to remove whichever role they currently have and add the new one.