Skip to content

Commit 55f39d2

Browse files
Create page.md
1 parent 605a565 commit 55f39d2

File tree

1 file changed

+32
-0
lines changed
  • src/app/docs/parameters/set-required

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: setRequired
3+
nextjs:
4+
metadata:
5+
title: setRequired
6+
description: Learn more about on how to set parameters as required or optional in NetWizard, this is helpful when you only want certain parameters from users which are absolutely requrired while having certain optional parameters.
7+
---
8+
9+
{% callout title="Note" %} This feature is available in NetWizard >= v1.2.0 {% /callout %}
10+
11+
All parameters by default are "required" in NetWizard which ultimately means it's necessary for user to enter all input parameters before proceeding to finish the setup.
12+
13+
While this approach is fine if all the parameters you are adding to NetWizard portal should be entered by user; but in certain scenarios where you have to keep some input parameters as optional then you may use the following API:
14+
15+
## API Reference
16+
17+
### Constructor Method
18+
19+
The 6th param in NetWizardParameter constructor is a boolean which can be set to `true` or `false` to toggle requiredness of the parameter. (`true` = required and `false` = optional)
20+
21+
```cpp
22+
// Input parameter as optional example
23+
NetWizardParameter nw_input(&NW, NW_INPUT, "Name", "Value", "Placeholder", false);
24+
```
25+
26+
### Function Method
27+
28+
Additionally, you can also toggle the requiredness of the parameter from anywhere in your code (apart from global scope) using the `setRequired` function.(`true` = required and `false` = optional)
29+
30+
```cpp
31+
nw_input.setRequired(false);
32+
```

0 commit comments

Comments
 (0)