You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/admin/templates/extending-templates/dynamic-parameters.md
+51-3Lines changed: 51 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -298,7 +298,7 @@ Using these in conjunction, administrators can build intuitive, reactive forms f
298
298
299
299
<divclass="tabs">
300
300
301
-
## Hide/show options
301
+
###Hide/show options
302
302
303
303
Using Terraform conditionals and the `count` block, we can allow a checkbox to expose or hide a subsequent parameter.
304
304
@@ -333,7 +333,7 @@ data "coder_parameter" "cpu_cores" {
333
333
}
334
334
```
335
335
336
-
## Dynamic Defaults
336
+
###Dynamic Defaults
337
337
338
338
For a given parameter, we can influence which option is selected by default based on the selection of another. This allows us to suggest an option dynamically without strict enforcement.
339
339
@@ -387,9 +387,57 @@ data "coder_parameter" "ide_selector" {
387
387
}
388
388
```
389
389
390
+
## Dynamic Validation
390
391
392
+
Parameters' validation block can also leverage inputs from other parameters.
391
393
392
-
## Dynamic Validation
394
+
[Try dynamic validation in the Parameter Playground](https://playground.coder.app/parameters/sdbzXxagJ4).
395
+
396
+
397
+
```terraform
398
+
data "coder_parameter" "git_repo" {
399
+
name = "git_repo"
400
+
display_name = "Git repo"
401
+
description = "Select a git repo to work on."
402
+
order = 1
403
+
mutable = true
404
+
type = "string"
405
+
form_type = "dropdown"
406
+
407
+
option {
408
+
# A Go-heavy repository
409
+
name = "coder/coder"
410
+
value = "coder/coder"
411
+
}
412
+
413
+
option {
414
+
# A python-heavy repository
415
+
name = "coder/mlkit"
416
+
value = "coder/mlkit"
417
+
}
418
+
}
419
+
420
+
data "coder_parameter" "cpu_cores" {
421
+
# Only show this parameter if the previous box is selected.
0 commit comments