Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update lib/nested_form/builder_mixin.rb #226

Closed
wants to merge 1 commit into from

2 participants

@achempion

I use twitter bootstrap and I needed use a tabs for my form
gem nested form make wrap all .simple_fields_for fields, but if it don't needed,
we can't disable it

like my nested has_many model for example:
%ul.nav.nav-tabs#project-tabs
  %li.active= link_to ...
  %li= link_to ...
.tab-content
  = f.simple_fields_for :project_contents do |content|
    .tab-pane
But if will make wrap simple_fields_for - it's will crashed tabs

For disable it, after commit - In your nested model
def self.wrapper_off?
  true
end

@achempion achempion Update lib/nested_form/builder_mixin.rb
I use twitter bootstrap and for my form and I needed use a tabs
gem nested form make wrap all .fields_for fields, but if it don't needed,
we can't disable it

like my nested has_many model for example:
%ul.nav.nav-tabs#project-tabs
  %li.active= link_to ...
  %li= link_to ...
.tab-content
  = f.simple_fields_for :project_contents do |content|
    .tab-pane
But if will make wrap fields_for - it's will crashed tabs

For disable it, after commit - In your nested model
def self.wrapper_off?
  true
end
89284f4
@achempion

But if we will use the fields_for instead simple_fields_for - all will be well

@lest
Collaborator

I think we shouldn't put wrapper_off? method to the model because it's a view-specific behavior.

I'm thinking about adding :nested_wrapper => false option as an alias to :wrapper => false. This should allow to use simple_fields_for without wrapping them into div.fields.

@achempion achempion referenced this pull request in plataformatec/simple_form
Closed

some problems with transfer options #718

@lest
Collaborator

I don't see any problems in the simple_form method you mentioned.

@achempion

simple_form_for can't transfer wrapper argument to form_for method

@lest
Collaborator

It's because simple_form uses wrapper option to specify which simple_form wrapper should be used. That is why I'm thinking about adding an alias to this option inside nested_form.

@achempion achempion referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@achempion achempion referenced this pull request in plataformatec/simple_form
Closed

some problems with transfer options #719

@achempion achempion referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@achempion achempion referenced this pull request in plataformatec/simple_form
Merged

some problems with transfer options #720

@achempion achempion closed this
@achempion achempion deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2012
  1. @achempion

    Update lib/nested_form/builder_mixin.rb

    achempion authored
    I use twitter bootstrap and for my form and I needed use a tabs
    gem nested form make wrap all .fields_for fields, but if it don't needed,
    we can't disable it
    
    like my nested has_many model for example:
    %ul.nav.nav-tabs#project-tabs
      %li.active= link_to ...
      %li= link_to ...
    .tab-content
      = f.simple_fields_for :project_contents do |content|
        .tab-pane
    But if will make wrap fields_for - it's will crashed tabs
    
    For disable it, after commit - In your nested model
    def self.wrapper_off?
      true
    end
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/nested_form/builder_mixin.rb
View
7 lib/nested_form/builder_mixin.rb
@@ -88,10 +88,15 @@ def fields_for_with_nested_attributes(association_name, *args)
end
def fields_for_nested_model(name, object, options, block)
+ begin
+ wrapper_off = true if object.class.wrapper_off?
+ rescue
+ wrapper_off = false
+ end
classes = 'fields'
classes << ' marked_for_destruction' if object.respond_to?(:marked_for_destruction?) && object.marked_for_destruction?
- if options[:wrapper] != false # wrap even if nil
+ if options[:wrapper] != false && wrapper_off != true # wrap even if nil
@template.content_tag(:div, super, :class => classes)
else
super
Something went wrong with that request. Please try again.