Wiki source code of XWikiSelect
Version 7.1 by Guillaume Delhumeau on 2015/09/08
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | = Summary = |
![]() |
3.1 | 2 | |
![]() |
1.1 | 3 | The XWiki select component is a widget that have the same objective than a regular select box, but styled nicely and with parameters like icons, descriptions, etc... |
4 | |||
5 | This is an example of use: | ||
6 | |||
![]() |
3.1 | 7 | {{image reference="xwiki-select.png"/}} |
![]() |
1.1 | 8 | |
9 | = How to use = | ||
![]() |
3.1 | 10 | |
![]() |
4.1 | 11 | This component is usable in any Wiki page or Velocity template. For a wiki page, you need to be both inside a ~{~{velocity}} and a ~{~{html}} macros. |
![]() |
1.1 | 12 | |
![]() |
4.1 | 13 | You just need to call the ###xwikiSelect()## macro with the following parameters: |
![]() |
1.1 | 14 | |
15 | * //fieldName//: name of the input field | ||
16 | * //options//: an array of maps describing a category of options, which contains an array of options (see example) | ||
17 | * //defaultValue//: the default value to use (could be null) | ||
![]() |
4.1 | 18 | * //firstIsDefaultIfDefaultNull//: either if //defaultValue// is null, select the first option or not |
![]() |
1.1 | 19 | * //cssClass//: class to add to the div (could be '##xwiki-select-small##', '##xwiki-select-medium##', '##xwiki-select-tall##' or any other class) |
20 | |||
21 | = Example of use = | ||
![]() |
3.1 | 22 | |
![]() |
5.1 | 23 | {{code language="plain"}} |
![]() |
1.1 | 24 | #set($options = [ |
25 | { | ||
26 | 'name': 'Category 1', | ||
27 | 'options': [ | ||
28 | { 'name': 'Option 1', 'value': 'option1', 'description': 'Description of the option 1', 'icon': 'wiki', 'data': {'some-data': 'some-value'}}, | ||
29 | { 'name': 'Option 2', 'value': 'option2', 'description': 'Description of the option 2', 'icon': 'page'} | ||
30 | ] | ||
31 | }, | ||
32 | { | ||
33 | 'name': 'Category 2', | ||
34 | 'options': [ | ||
35 | { 'name': 'Option 3', 'value': 'option3', 'description': 'Description of the option 3', 'icon': 'check'} | ||
36 | ] | ||
37 | } | ||
38 | ]) | ||
39 | #xwikiSelect('nameOfTheField', $options, 'option1', false, 'xwiki-select-small') | ||
40 | {{/code}} | ||
![]() |
7.1 | 41 | |
42 | Generates: | ||
43 | |||
44 | {{image reference="example.png"/}} |