How to template a drop-down selection and checkbox in a form
RaphaelBossek opened this issue · 3 comments
I'm trying to template this but do not have a clue how to.
The questions are
- What kind of
data-valueanddata-template-binddo I need? - How does the JSON data structure looks like for the
data-valueanddata-template-bind?
Example 1: Drop-down selection
<select class="select" id="color_selection" name="color">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="yellow" selected>Yellow</option>
</select>How to select the Yellow color?
Example 2: Checkbox
<form action="demo_form.asp">
<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car" checked> I have a car<br>
<input type="submit" value="Submit">
</form>How to checkbox the Car?
I don't know. You've just given me plain html. If you haven't already got json data that you are trying to insert you are probably using the plugin for the wrong reason. If you can give me some more information as to what is static, and what is dynamic data then I can potentially help.
Ok, here is a JSON data structure:
{
"name": "011 Technical Risk"
"weighting": 10
"comment": "What is the probability of overcoming the technical challenges of the project?"
"typeofindex": "PERCENTAGE"
"bignummerbetter": true
"typeofindexdescription": ""
}typeofindex is an enum(eration) of following valid values:
INCOMPLETEPLANNING_POKERCHRONOLOGICAL_ORDERPERCENTAGEREFERENCE_QUANTITY
bignumberbetter is an boolean, so valid values are:
truefalse
For the enum(eration) I would like to use a drop-down list. For the boolean an checkbox.
I believe you should be able to do this by binding the value property of the select to typeofindex and potentially use a formatter to bind the checked attribute of the checkbox to bignumberbetter (to convert the true/false into what you need)