Editor Select Field
Editor Select Field
andrew beever
Posts: 12Questions: 6Answers: 0
I have a form with a select field.
The users accessing this form need to be presented with a subset of the possible options for this field dependent on their permissions.
I wondered if there was a smart way with Editor to create only a subset of options, or is the best way to remove the unwanted options after Editor has created the full list?
Thank you
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Either way works!
You can define options with subsets and assign them to the field or dynamically delete some. I guess the latter is a bit more work. I do it in a case when the options are fully dynamic. In your case that would mean the user rights change within one session which probably isn't your use case.
Here is an example where I assign different predefined options (global variables) depending on the respective financial instrument:
Thank you so much for your response. Your assumption is correct the regarding the user rights not changing within the session. Your suggestion is a very elegant solution!
Glad I could help! For the sake of completeness here is an example for the more complicated version of dynamic options:
In case you have interdependencies between fields and the options of field b and c need to be adjusted based on selections in field a (or field b with respect to field c) this is an example on how to handle that by changing the options fully dynamically. This solution may look a bit awkward: It avoids updating editor fields if the value hasn't changed because this may cause performance issues under certain circumstances. Hence I use global variables to save the options before they change to be able to compare them.
Since options are arrays of simple objects you need to make shallow copies using slice() for example.
Wow, thank you once again!