-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi,
It would be perfect if Formlet is also able to save checkboxes state based solely on their value. Unfortunately Formlet is not able to select them.
Example Form (http://foundation.zurb.com/develop/download.html#customizeFoundation):
<input type="checkbox" name="scss_components[]" value="foundation/components/grid" checked="checked">
<input type="checkbox" name="scss_components[]" value="foundation/components/block-grid">
I have altered the saved bookmarklet so it is now able to select those checkboxes:
endsWith: function(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
},
getElement: function(form, name, index, value) {
var element;
if (value && methods.endsWith(name, "[]")) {
element = form.querySelector('input[name="'+name+'"][value="'+value+'"]');
}
else {
element = form[name][index] || form[name];
}
return element;
},
Saved data now look like this:
"elements": [
["input-name[]", null, "input-value", "setChecked", true],
["scss_components[]", null, "foundation\\/components\\/grid", "setChecked", true],
["basic-input", null, null, "setValue", "Hello!"],
]
The code needs some polishing, but it works.
It would be great if you could build an enhancement around it and include it in the future release of Formlet.
Metadata
Metadata
Assignees
Labels
No labels