Skip to content

Commit 95e171d

Browse files
committed
adding form types
1 parent fa5ee37 commit 95e171d

File tree

1 file changed

+104
-18
lines changed

1 file changed

+104
-18
lines changed

docs/admin/templates/extending-templates/dynamic-parameters.md

Lines changed: 104 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Dynamic Parameters (Beta)
22

3-
Coder v2.24.0 introduces Dynamic Parameters to extend the existing parameter system with conditional form controls, enriched input types, and user idenitity awareness.
4-
This feature allows template authors to create interactive workspace creation forms, meaning more environment customization and fewer templates to maintain.
3+
Coder v2.24.0 introduces Dynamic Parameters to extend the existing parameter system with conditional form controls, enriched input types, and user idenitity awareness.
4+
This feature allows template authors to create interactive workspace creation forms, meaning more environment customization and fewer templates to maintain.
55

6-
All parameters are parsed from Terraform, meaning your workspace creation forms live in the same location as your provisioning code. You can use all the native Terraform functions and conditionality to create a self-service tooling catalog for every template.
6+
All parameters are parsed from Terraform, meaning your workspace creation forms live in the same location as your provisioning code. You can use all the native Terraform functions and conditionality to create a self-service tooling catalog for every template.
77

88
Administrators can now:
99

1010
- Create parameters which respond to the inputs of others
1111
- Only show parameters when other input criteria is met
1212
- Only show select parameters to target Coder roles or groups
1313

14-
You can try the dynamic parameter syntax and any of the code examples below in the [Parameters Playground](https://playground.coder.app/parameters) today. We advise experimenting here before upgrading templates.
14+
You can try the dynamic parameter syntax and any of the code examples below in the [Parameters Playground](https://playground.coder.app/parameters) today. We advise experimenting here before upgrading templates.
1515

1616
### When you should upgrade to Dynamic Parameters
1717

@@ -25,13 +25,13 @@ There are three reasons for users to try Dynamic Parameters:
2525
- You want to selectively expose privledged workspace options to admins, power users, or personas
2626
- You want to make the workspace creation flow more ergonomic for developers.
2727

28-
Dynamic Parameters help you reduce template duplication by setting conditions on which users may see which parameters. They increase the potential complexity of user-facing configuration by allowing administrators to organize a long list of options into interactive, branching paths for workspace customization. They allow you to set resource guardrails by referencing coder identity in the `coder_workspace_owner` data source.
28+
Dynamic Parameters help you reduce template duplication by setting conditions on which users may see which parameters. They increase the potential complexity of user-facing configuration by allowing administrators to organize a long list of options into interactive, branching paths for workspace customization. They allow you to set resource guardrails by referencing coder identity in the `coder_workspace_owner` data source.
2929

3030
Read on for setup steps and code examples.
3131

3232
### How to enable Dynamic Parameters
3333

34-
In v2.24.0, you can opt-in to Dynamic Parameters on a per-template basis. To use dynamic parameters, go to your template settings and toggle the "Enable Dynamic Parameters Beta" option.
34+
In v2.24.0, you can opt-in to Dynamic Parameters on a per-template basis. To use dynamic parameters, go to your template settings and toggle the "Enable Dynamic Parameters Beta" option.
3535

3636
[Image of template settings with dynamic parameters beta option]
3737

@@ -106,6 +106,8 @@ The "Options" column in the table below indicates whether the form type requires
106106

107107
### New Form Types
108108

109+
The [`form_type`](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/parameter#form_type-1) attribute can be used to select from a variety of form controls. See the following examples for usage in the [Parameters Playground](https://playground.coder.app/parameters).
110+
109111
<tabs>
110112

111113
## Dropdown lists
@@ -146,11 +148,91 @@ data "coder_parameter" "ides_dropdown" {
146148
```
147149

148150

149-
## Large text entry
151+
## Text area
152+
153+
The large text entry option can be used to enter long strings like AI prompts, scripts, or natural language.
154+
155+
[Try textarea parameters on the Parameter Playground](https://playground.coder.app/parameters/RCAHA1Oi1_)
156+
157+
158+
```terraform
159+
160+
data "coder_parameter" "text_area" {
161+
name = "text_area"
162+
description = "Enter mutli-line text."
163+
mutable = true
164+
display_name = "Select mutliple IDEs"
165+
166+
form_type = "textarea"
167+
type = "string"
168+
169+
default = <<-EOT
170+
This is an example of mult-line text entry.
171+
172+
The 'textarea' form_type is useful for
173+
- AI prompts
174+
- Scripts
175+
- Read-only info (try the 'disabled' styling option)
176+
EOT
177+
}
178+
179+
```
150180

151181
## Multi-select
152182

183+
Multi-select parameters allow users to select one or many options from a single list of options. For example, adding multiple IDEs with a single parameter.
184+
185+
[Try multi-select parameters on the Parameter Playground](https://playground.coder.app/parameters/XogX54JV_f)
186+
187+
```terraform
188+
locals {
189+
ides = [
190+
"VS Code", "JetBrains IntelliJ",
191+
"GoLand", "WebStorm",
192+
"Vim", "Emacs",
193+
"Neovim", "PyCharm",
194+
"Databricks", "Jupyter Notebook",
195+
]
196+
}
197+
198+
data "coder_parameter" "ide_selector" {
199+
name = "ide_selector"
200+
description = "Choose any IDEs for your workspace."
201+
mutable = true
202+
display_name = "Select mutliple IDEs"
203+
204+
205+
# Allows users to select multiple IDEs from the list.
206+
form_type = "multi-select"
207+
type = "list(string)"
208+
209+
210+
dynamic "option" {
211+
for_each = local.ides
212+
content {
213+
name = option.value
214+
value = option.value
215+
}
216+
}
217+
}
218+
```
219+
220+
## Checkboxes
221+
222+
223+
Checkbox: A single checkbox for boolean values
153224

225+
[Try checkbox parameters on the playground](https://playground.coder.app/parameters/ycWuQJk2Py)
226+
227+
```terraform
228+
data "coder_parameter" "enable_gpu" {
229+
name = "enable_gpu"
230+
display_name = "Enable GPU"
231+
type = "bool"
232+
form_type = "checkbox" # This is the default for boolean parameters
233+
default = false
234+
}
235+
```
154236

155237
</tabs>
156238

@@ -160,6 +242,19 @@ data "coder_parameter" "ides_dropdown" {
160242

161243
<tabs>
162244

245+
## Conditionally hide parameters
246+
247+
```terraform
248+
249+
250+
```
251+
252+
253+
## Dynamic Defaults
254+
255+
256+
##
257+
163258

164259

165260
</tabs>
@@ -172,24 +267,15 @@ data "coder_parameter" "ides_dropdown" {
172267

173268
## Role-specific options
174269

175-
##
270+
## Groups as namespaces
176271

177272
</tabs>
178273

179274

180275
### Form Type Examples
181276

182-
<details><summary>checkbox: A single checkbox for boolean values</summary>
277+
<details><summary></summary>
183278

184-
```tf
185-
data "coder_parameter" "enable_gpu" {
186-
name = "enable_gpu"
187-
display_name = "Enable GPU"
188-
type = "bool"
189-
form_type = "checkbox" # This is the default for boolean parameters
190-
default = false
191-
}
192-
```
193279

194280
</details>
195281

0 commit comments

Comments
 (0)