Adding Forms and Fields
Using with a looping attribute - vdl-repeat - it is easy to generate form fields from elements in an array.
<vdl version="4.1"> <vdl-page> <vdl-section heading="Welcome to Portfolio Optimization" heading-level="1"> <vdl-section heading="Return per share type" heading-level="2"> <vdl-form vdl-repeat="=s in scenario.entities.SHARES"> <vdl-field entity="RET" indices="=s.value" label="=s.label"> </vdl-field> </vdl-form> <vdl-execute-button caption="Run scenario"></vdl-execute-button> </vdl-section> <vdl-section heading="Optimal result" heading-level="2"> <span vdl-text="Calculated optimal return: "></span> <span vdl-text="=insight.Formatter.formatNumber (scenario.entities.Return.value, '.##')"> </span> </vdl-section> <vdl-section heading="Recommended share allocations" heading-level="3"> <vdl-table page-mode="paged" page-size="5" show-filter="true" column-filter="true"> <vdl-table-column entity="frac"></vdl-table-column> <vdl-table-column entity="RET"></vdl-table-column> </vdl-table> </vdl-section> </vdl-section> </vdl-page> </vdl>These additions introduce some powerful new concepts.
First, <vdl-form> is used to begin a form.
Then, the vdl-repeat attribute is assigned to an expression =s in scenario.entities.SHARES which iterates over the SHARES entity. For each value s discovered in the collection, a <vdl-field> element is created, based on the RET entity and indexed by the value of the discovered share type. Finally, the field label has to be changed each time, and so it is set to be the same as the label from the share index.
Also note the new <vdl-execute-button> element which can be placed anywhere in a view (not just within the confines of a form like an HTML submit button) to offer an effortless way to (re)run the scenario.

Creating Forms and Fields with vdl-repeat
By default, editing is enabled in VDL fields, and you can overtype the field values in the Return per share section, click Run Scenario to (re)run the scenario and review the new results.