Skip to content

Instantly share code, notes, and snippets.

@adamw
Created March 4, 2015 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamw/3080a568e05c4f4529e1 to your computer and use it in GitHub Desktop.
Save adamw/3080a568e05c4f4529e1 to your computer and use it in GitHub Desktop.
supler options
new SuplerForm(document.getElementById("container"), {
field_options: {
"age": {
// define render hint on frontend
"render_hint": "number"
},
"dateOfBirth": {
"after_render": function(inputElement, containerElement) {
$(inputElement).datepicker();
}
},
"bio": {
"render_hint": { "name": "textarea", "rows": 10, "cols": 40 },
render_options: {
renderLabel: function(forId, label) { return label; /* some html */ }
// override any other methods from RenderOptions returning HTML:
// renderStringField, renderField, renderHtmlInput, renderHtmlButton etc.
}
},
"friends[].likes": {
"render_hint": "radio"
},
// matches all fields with render hint == radio
"render_hint:radio": {
render_options: {
// override methods from RenderOptions
}
},
// common options for all fields
"*": {
// ...
}
},
// if multiple templates match an element, first templates/options for exact field-path are taken into
// account, then for render hints. If multiple again, override from field_options have precedence, then
// as defined here.
// by default includes the form container as the first element (-> form container can contain field templates)
"field_templates": [ "idOfElementWithTemplates1", "idOfElementWithTemplates2" ],
"form_options": {
// override field order
"field_order": [ "age", "bio" ],
// template of whole form layout
"form_layout_template": "idOfElementContainingTemplate"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment