Adding columnized output support to "PredefinedOptions" tag [5.2.1-RC1]
The "PredefinedOptions" tag is the core of all form controls, where user can select something from predefined set of options. For example:
inp_edit_options - dropdown with a list of options
inp_edit_radio - list of radio buttons
inp_edit_checkboxes - list of checkboxes, where multiple checkboxes can be selected at once
The tag is good at what it does, but when it comes to more advanced stuff (see list below), then it's pretty hard to it.
displaying list of options split across several columns
displaying only selected options
both from above combined
Typical PredefinedOptions tag usage the in template
<inp2:m_DefineElement name="checkbox_option_element">
<li>
<inp2:m_Param name="option"/>
</li>
</inp2:m_DefineElement>
<ul>
<inp2:unit-prefix_PredefinedOptions field="FieldName" block="checkbox_option_element" selected="selected"/>
</ul>Parameters added for "PedefinedOptions" tag
Parameter Name | Parameter Description |
|---|---|
selected_only | display only selected options (without this all options will be displayed) |
columns | indicate column count to split displayed options into |
Also now the "selected" parameter default to "selected" value, when no given explicitly in tag. This would allow to write less code to do same task as before.
Parameters added to block, specified in "block" parameter to "PredefinedOptions" tag
Parameter Name | Parameter Description |
|---|---|
column_number | currently printed column number |
column_changed | flag, that is only set when a column change occurs (let "block" to decide how to handle that) |
option_number | order number of the option in the list (starting from 1) |
option_count | total option count that will be printed |
Usage examples
For we're having following options list:
Option Key | Option Title |
|---|---|
100 | Option One |
200 | Option Two |
300 | Option Three |
400 | Option Four |
500 | Option Five |
Using "columns", "column_changed" and "column_number" parameters
<inp2:m_DefineElement name="checkbox_option_element">
<inp2:m_if check="m_Param" name="column_changed">
</ul>
<ul class="column-<inp2:m_Param name='column_number'/>">
</inp2:m_if>
<li>
<inp2:m_Param name="option_number"/>. <inp2:m_Param name="option"/> (key: <inp2:m_Param name="key"/>)
</li>
</inp2:m_DefineElement>
<ul class="column-1">
<inp2:unit-prefix_PredefinedOptions field="FieldName" block="checkbox_option_element" columns="3"/>
<ul>The example from above would produce following output:
<ul class="column-1">
<li>1. Option One (key: 100)</li>
<li>2. Option Two (key: 200)</li>
<ul>
<ul class="column-2">
<li>3. Option Three (key: 300)</li>
<li>4. Option Four (key: 400)</li>
<ul>
<ul class="column-3">
<li>5. Option Five (key: 500)</li>
<ul>