# `PhoenixKitWeb.ContextController`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/phoenix_kit_web/controllers/context_controller.ex#L1)

Controller for handling dashboard context switching.

Provides POST endpoints that set the selected context ID(s) in the session
and redirect back to the referring page.

## Routes

- `POST /context/:id` - Legacy single selector (backward compatible)
- `POST /context/:key/:id` - Multi-selector with keyed context

## Multi-Selector Behavior

When using multiple selectors, changing a parent selector will automatically
reset dependent selectors based on their `on_parent_change` configuration:

- `:reset` (default) - Clears the dependent selector's stored ID
- `:keep` - Preserves the dependent selector's stored ID
- `{:redirect, path}` - Redirects to specified path instead of referer

# `set`

Sets the current context for a specific selector key.

This is the multi-selector route that handles `POST /context/:key/:id`.

## Parameters

- `key` - The selector key (e.g., "organization", "project")
- `id` - The context ID to set as current

## Response

Redirects to the referer URL, or `/dashboard` if no referer is present.
Dependent selectors may be reset based on their `on_parent_change` setting.

# `set_legacy`

Sets context using the legacy single-selector session key.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
