diff --git a/README.rdoc b/README.rdoc index f553686..5fdb6be 100644 --- a/README.rdoc +++ b/README.rdoc @@ -125,7 +125,7 @@ Just like the is_form_creator mixin, this mixin adds a polymorphic relationship * Radio Button Select * If the field is required make the first form_field_option by position (order) selected by default is the form_submission value for that field is blank * If the user chooses a different option and the form submission is invalid the option chose stays selected (this is expected behavior) -* Time Seelct +* Time Select * Date Select * Datetime Select @@ -172,7 +172,7 @@ validation_types: the available validations, defaults to all available. The re valid_mime_types: for file fields this is the default list of mimetypes that are valid. These can be customized on a per field basis or edit the default array. -== OVERIDING FUNCTIONALITY +== OVERRIDING FUNCTIONALITY === Controllers @@ -189,7 +189,7 @@ which defines the following: end You can see that the controllers are in the DynamicForms namespace. This means overriding them is pretty easy. -All you need to do is create a new controller that is a subclass of a DyanmicForms controller. For Example: +All you need to do is create a new controller that is a subclass of a DynamicForms controller. For Example: class FormsController < DynamicForms::FormsController def new @@ -199,7 +199,7 @@ All you need to do is create a new controller that is a subclass of a DyanmicFor end end -And then you must add a new route definition above the dyanmic forms generated route in your routes file as any routes defined first take precedence. +And then you must add a new route definition above the dynamic forms generated route in your routes file as any routes defined first take precedence. map.resources :forms, :controller => 'forms' DynamicForms::Routes.draw(map) @@ -213,7 +213,7 @@ The good news is that you only need to have the actions that you need to overrid === Views To change the views (which will need to happen in almost every case), -just copy the view folder that you want out of vendor/plugins/dyamic_forms/app/views and put it in app/views. +just copy the view folder that you want out of vendor/plugins/dynamic_forms/app/views and put it in app/views. You don't have to change every view either, you could only copy the views that you plan on changing. @@ -250,7 +250,7 @@ For example, if you always want to include a blank option on a select no matter * Default Stylesheet * Add a helper method to include the dynamic_forms public assets in the template - * Have stylsheet and JS tags (multiple tags for the different JS lib files) + * Have stylesheet and JS tags (multiple tags for the different JS lib files) * More Field Choices * Country Select Field (use a plugin => http://github.com/rails/country_select) diff --git a/lib/dynamic_forms/models/form_field.rb b/lib/dynamic_forms/models/form_field.rb index 2d7d36c..7e20c56 100644 --- a/lib/dynamic_forms/models/form_field.rb +++ b/lib/dynamic_forms/models/form_field.rb @@ -110,7 +110,7 @@ def field_helper_select_options private def assign_name - self.name = "field_" + Digest::SHA1.hexdigest(self.label + Time.now.to_s).first(20) if self.name.blank? + self.name = "field_" + Digest::SHA1.hexdigest(self.label + self.position.to_s + Time.now.to_s).first(20) if self.name.blank? end end diff --git a/public/javascripts/dynamic_forms_prototype.js b/public/javascripts/dynamic_forms_prototype.js index c0b25c6..59e8b38 100644 --- a/public/javascripts/dynamic_forms_prototype.js +++ b/public/javascripts/dynamic_forms_prototype.js @@ -52,12 +52,12 @@ function remove_field(link) { $(link).up('.field').hide(); // Get the position element for the field that is being removed and get the value - // Remove the position element from the DOM + // Set the value of the position element to an empty string // Get the parent container of the form field // Cycle through the the hidden position elements and if the value is greater than the value that was removed, decrement by 1 var position = $(link).up('.field').getElementsBySelector('.field_position').first(); var position_value = position.value; - position.remove(); + position.value = ""; var parent_container = $('form_fields'); parent_container.getElementsBySelector(".field_position").each(function(n) { if(parseInt(n.value) > position_value) { @@ -72,12 +72,12 @@ function remove_field_option(link) { $(link).up('.option').hide(); // Get the position element for the option that is being removed and get the value - // Remove the position element from the DOM + // Set the value of the position element to an empty string // Get the parent container of the form field options // Cycle through the the hidden position elements and if the value is greater than the value that was removed, decrement by 1 var position = $(link).up().previous("input[type=hidden]"); var position_value = position.value; - position.remove(); + position.value = ""; var parent_container = $(link).up(".form_field_options"); parent_container.getElementsBySelector(".field_option_position").each(function(n) { if(parseInt(n.value) > position_value) {