-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
49 lines (47 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
/**
* radio Input Plugin
*
*
* A plugin for multiple radio buttons
*/
const validation = require('./lib/validation.js');
/**
* Single radio Input Plugin
* @module radioInputPlugin
*/
module.exports = {
name: 'radio',
description: 'A plugin for multiple radio buttons',
validation: {
radioValidation: validation,
},
inputs: {
radio: {
validation: {
function: 'radioValidation',
on: 'change',
},
type: 'radio',
label: 'radio',
options: [
{ label: 'red',
value: 'red',
},
{ label: 'blue',
value: 'blue',
},
{ label: 'green',
value: 'green',
},
{ label: 'yellow',
value: 'yellow',
},
],
settings: {
empty: false,
},
},
},
html: '<ul>{% for option in radio.options %}<li><input type="{{radio.type}}" name="{{radio.name}}" id="{{radio.id}}--{{loop.index}}" value="{{option.value}}" {% if option.value == radio.value %}checked{% endif %}><label for="{{radio.id}}--{{loop.index}}">{{option.label}}</label></li>{% endfor %}</ul>',
};