Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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.

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamic_forms/models/form_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions public/javascripts/dynamic_forms_prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down