Permalink
Browse files

Merging

  • Loading branch information...
viveleroi committed Mar 2, 2013
2 parents f0ce117 + fffc3f9 commit 7cd0528dfe5d0772bf2ebed6c7efec8d08965ae9
Showing with 48 additions and 26 deletions.
  1. +11 −15 README.md
  2. +37 −11 js/jquery.formbuilder.js
View
@@ -1,26 +1,22 @@
jQuery.FormBuilder
==================
-The jquery.Formbuilder plugin is a jQuery plugin that allows you add a
-form-creation, display, and basic validation tool into your application.
-The API and example code has been left open for you to override,
-assuming that you want complete control over how the form data is saved
-and loaded. However we have provided some basic database loading/saving
-examples using PDO for MySQL.
+The jquery.Formbuilder plugin is a jQuery plugin that allows you add a form-creation, display, and basic validation tool into your application.
-Please report all issues, bugs, and feature suggestions
-to: https://snowy-evening.com/botsko/jquery-form-builder/
+The API and example code has been left open for you to override, assuming that you want complete control over how the form data is saved and loaded. However we have provided some basic database loading/saving examples using PDO for MySQL.
-The tool interface is constructed using form data presented in JSON
-format by the server. The php class assists you with storing the data,
-generating the json, generating the html form, and processing the data.
+Please report all issues, bugs, and feature suggestions to: https://snowy-evening.com/botsko/jquery-form-builder/
-A demo of this version may be found at
-http://botsko.net/Demos/formbuilder/
+The tool interface is constructed using form data presented in JSON format by the server. The php class assists you with storing the data, generating the json, generating the html form, and processing the data.
-Please feel free to fork the project and provide patches back.
-Please let us know how you're using this product!
+A demo of this version may be found at http://botsko.net/Demos/formbuilder/
+Please feel free to fork the project and provide patches back. Please let us know how you're using this product!
+
+### Version 0.4.1 - 20130302
+
+- Fixing required/baseline checked state being read incorrectly
+- Adding ability to sort/reorder fields, PR by anjana-somathilake
### Version 0.4 - 20111215
- Removing old XML-based form loading system, moving to pure JSON
View
@@ -14,6 +14,7 @@
load_url: false,
control_box_target: false,
serialize_prefix: 'frmb',
+ css_ol_sortable_class : 'ol_opt_sortable',
messages: {
save : "Save",
add_new_field : "Add New Field...",
@@ -179,6 +180,9 @@
field += '<input type="text" name="title" value="' + title + '" /></div>';
field += '<div class="false-label">' + opts.messages.select_options + '</div>';
field += '<div class="fields">';
+
+ field += '<div><ol class="' + opts.css_ol_sortable_class + '">';
+
if (typeof (values) === 'object') {
for (i = 0; i < values.length; i++) {
field += checkboxFieldHtml(values[i]);
@@ -187,11 +191,16 @@
else {
field += checkboxFieldHtml('');
}
+
+ field += '</ol></div>';
+
field += '<div class="add-area"><a href="#" class="add add_ck">' + opts.messages.add + '</a></div>';
field += '</div>';
field += '</div>';
help = '';
appendFieldLi(opts.messages.checkbox_group, field, required, help);
+
+ $('.'+ opts.css_ol_sortable_class).sortable(); // making the dynamically added option fields sortable.
};
// Checkbox field html, since there may be multiple
var checkboxFieldHtml = function (values) {
@@ -201,12 +210,12 @@
value = values[0];
checked = ( values[1] === 'false' || values[1] === 'undefined' ) ? false : true;
}
- field = '';
+ field = '<li>';
field += '<div>';
field += '<input type="checkbox"' + (checked ? ' checked="checked"' : '') + ' />';
field += '<input type="text" value="' + value + '" />';
field += '<a href="#" class="remove" title="' + opts.messages.remove_message + '">' + opts.messages.remove + '</a>';
- field += '</div>';
+ field += '</div></li>';
return field;
};
// adds a radio element
@@ -220,6 +229,9 @@
field += '<input type="text" name="title" value="' + title + '" /></div>';
field += '<div class="false-label">' + opts.messages.select_options + '</div>';
field += '<div class="fields">';
+
+ field += '<div><ol class="' + opts.css_ol_sortable_class + '">';
+
if (typeof (values) === 'object') {
for (i = 0; i < values.length; i++) {
field += radioFieldHtml(values[i], 'frm-' + last_id + '-fld');
@@ -228,11 +240,16 @@
else {
field += radioFieldHtml('', 'frm-' + last_id + '-fld');
}
+
+ field += '</ol></div>';
+
field += '<div class="add-area"><a href="#" class="add add_rd">' + opts.messages.add + '</a></div>';
field += '</div>';
field += '</div>';
help = '';
appendFieldLi(opts.messages.radio_group, field, required, help);
+
+ $('.'+ opts.css_ol_sortable_class).sortable(); // making the dynamically added option fields sortable.
};
// Radio field html, since there may be multiple
var radioFieldHtml = function (values, name) {
@@ -242,12 +259,13 @@
value = values[0];
checked = ( values[1] === 'false' || values[1] === 'undefined' ) ? false : true;
}
- field = '';
+ field = '<li>';
field += '<div>';
field += '<input type="radio"' + (checked ? ' checked="checked"' : '') + ' name="radio_' + name + '" />';
field += '<input type="text" value="' + value + '" />';
field += '<a href="#" class="remove" title="' + opts.messages.remove_message + '">' + opts.messages.remove + '</a>';
- field += '</div>';
+ field += '</div></li>';
+
return field;
};
// adds a select/option element
@@ -266,19 +284,27 @@
field += '<div class="fields">';
field += '<input type="checkbox" name="multiple"' + (multiple ? 'checked="checked"' : '') + '>';
field += '<label class="auto">' + opts.messages.selections_message + '</label>';
- if (typeof (values) === 'object') {
- for (i = 0; i < values.length; i++) {
- field += selectFieldHtml(values[i], multiple);
+
+ field += '<div><ol class="' + opts.css_ol_sortable_class + '">';
+
+ if (typeof (values) === 'object') {
+ for (i = 0; i < values.length; i++) {
+ field += selectFieldHtml(values[i], multiple);
+ }
}
- }
- else {
- field += selectFieldHtml('', multiple);
- }
+ else {
+ field += selectFieldHtml('', multiple);
+ }
+
+ field += '</ol></div>';
+
field += '<div class="add-area"><a href="#" class="add add_opt">' + opts.messages.add + '</a></div>';
field += '</div>';
field += '</div>';
help = '';
appendFieldLi(opts.messages.select, field, required, help);
+
+ $('.'+ opts.css_ol_sortable_class).sortable(); // making the dynamically added option fields sortable.
};
// Select field html, since there may be multiple
var selectFieldHtml = function (values, multiple) {

0 comments on commit 7cd0528

Please sign in to comment.