|
38 | 38 | <body> |
39 | 39 |
|
40 | 40 | <mm-form id="testForm" unresolved> |
| 41 | + |
41 | 42 | <div class="col" span="1"> |
42 | 43 | <mm-input fitparent name="input" placeholder="Type a Number"></mm-input> |
43 | 44 | </div> |
| 45 | + |
44 | 46 | <div class="col" span="1"> |
45 | 47 | <mm-dropdown fitparent name="dropdown" placeholder="Select an Item"> |
46 | 48 | <mm-list-item>List Item 1</mm-list-item> |
|
49 | 51 | <mm-list-item>List Item 4</mm-list-item> |
50 | 52 | </mm-dropdown> |
51 | 53 | </div> |
| 54 | + |
52 | 55 | <div class="col" span="2"> |
53 | 56 | <mm-group fitparent unresolved name="radio"> |
54 | 57 | <mm-radio> |
|
62 | 65 | </mm-radio> |
63 | 66 | </mm-group> |
64 | 67 | </div> |
| 68 | + |
| 69 | + <div class="col" span="4"> |
| 70 | + <mm-repeater id="repeater" name="repeater"> |
| 71 | + <template preserve-content> |
| 72 | + <mm-input name="name"></mm-input> |
| 73 | + <mm-dropdown name="firstOption"> |
| 74 | + <mm-list-item>Test Item 1</mm-list-item> |
| 75 | + <mm-list-item>Test Item 2</mm-list-item> |
| 76 | + <mm-list-item>Test Item 3</mm-list-item> |
| 77 | + <mm-list-item>Test Item 4</mm-list-item> |
| 78 | + </mm-dropdown> |
| 79 | + <mm-group name="secondOption"> |
| 80 | + <mm-radio><label>Test 1</label></mm-radio> |
| 81 | + <mm-radio><label>Test 2</label></mm-radio> |
| 82 | + <mm-radio><label>Test 3</label></mm-radio> |
| 83 | + </mm-group> |
| 84 | + </template> |
| 85 | + </mm-repeater> |
| 86 | + </div> |
| 87 | + |
65 | 88 | </mm-form> |
66 | 89 |
|
67 | 90 | <!-- config via markup --> |
|
117 | 140 |
|
118 | 141 | // config/initial data set up this way: |
119 | 142 | var config = { |
120 | | - 'input' : { |
121 | | - validation: 'int|empty', |
122 | | - parentEle: null, |
123 | | - errorMsgEle: null, |
124 | | - errorMsg: 'You need to type a number', |
125 | | - label: 'Type a number' |
126 | | - }, |
127 | | - 'dropdown' : { |
128 | | - validation: 'empty', |
129 | | - parentEle: null, |
130 | | - errorMsg: 'You need to select an item', |
131 | | - label: 'Select an Item' |
132 | | - }, |
133 | | - 'radio' : { |
134 | | - validation: function(name, value, data) { |
135 | | - return data[name] === 'Red' && value === 'Red'; |
| 143 | + 'input' : { |
| 144 | + validation: 'int|empty', |
| 145 | + parentEle: null, |
| 146 | + errorMsgEle: null, |
| 147 | + errorMsg: 'You need to type a number', |
| 148 | + label: 'Type a number' |
| 149 | + }, |
| 150 | + 'dropdown' : { |
| 151 | + validation: 'empty', |
| 152 | + parentEle: null, |
| 153 | + errorMsg: 'You need to select an item', |
| 154 | + label: 'Select an Item' |
136 | 155 | }, |
137 | | - parentEle: null, |
138 | | - errorMsgEle: null, |
139 | | - errorMsg: 'You need to select \'Red\'', |
140 | | - label: 'Select a Color' |
141 | | - }, |
142 | | - // 'empty' : {} |
143 | | - }; |
| 156 | + 'radio' : { |
| 157 | + validation: function(name, value, data) { |
| 158 | + return data[name] === 'Red' && value === 'Red'; |
| 159 | + }, |
| 160 | + parentEle: null, |
| 161 | + errorMsgEle: null, |
| 162 | + errorMsg: 'You need to select \'Red\'', |
| 163 | + label: 'Select a Color' |
| 164 | + }, |
| 165 | + 'repeater': { |
| 166 | + validation: function(name, value, data, field, view) { |
| 167 | + return field.validate(); |
| 168 | + }, |
| 169 | + parentEle: null, |
| 170 | + errorMsgEle: null, |
| 171 | + errorMsg: 'You need to select some stuff', |
| 172 | + label: 'Repeat Things' |
| 173 | + } |
| 174 | + // 'empty' : {} |
| 175 | + }; |
144 | 176 |
|
145 | 177 | // data that holds any actual values |
146 | 178 | // var data = { |
|
158 | 190 | // }; |
159 | 191 |
|
160 | 192 | window.addEventListener('WebComponentsReady', function(e) { |
161 | | - var testForm = document.querySelector('#testForm'); |
| 193 | + var testForm = document.querySelector('#testForm'), |
| 194 | + repeater = document.querySelector('#repeater'); |
162 | 195 |
|
163 | 196 | // Ordering! |
164 | 197 | testForm.config = config; |
165 | 198 | // testForm.data = data; |
166 | 199 |
|
| 200 | + |
| 201 | + |
167 | 202 | testForm.addEventListener('serialize-form', function(e){ |
168 | 203 | console.log('serialize-form', e.detail); |
169 | 204 | }); |
|
0 commit comments