-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple form wrappers break with new entries #591
Comments
Ha, cool, never specified the |
Looking into this, it's clear the custom SimpleForm wrappers aren't being passed. The major difference being that the The question is how to get cocoon to pass along the arguments of these options hashes from At first, I suspected the issue might be this line of code for render_options = received_render_options.dup E.g. could Rather, it looks more that the issue is with how def render_association(association, f, new_object, form_name, received_render_options={}, custom_partial=nil)
partial = get_partial_path(custom_partial, association)
render_options = received_render_options.dup
locals = render_options.delete(:locals) || {}
ancestors = f.class.ancestors.map{|c| c.to_s}
method_name = ancestors.include?('SimpleForm::FormBuilder') ? :simple_fields_for : (ancestors.include?('Formtastic::FormBuilder') ? :semantic_fields_for : :fields_for)
f.send(method_name, association, new_object, {:child_index => "new_#{association}"}.merge(render_options)) do |builder|
partial_options = {form_name.to_sym => builder, :dynamic => true}.merge(locals)
render(partial, partial_options)
end
end It appears the <div id="derivatives">
<div class="row">
<%= f.simple_fields_for :derivatives,
wrapper: :floating_labels_form,
wrapper_mappings: {
select: :floating_labels_select
} do |d| %>
<div class="col">
<%= render 'derivative_fields', f: d %>
</div>
<% end %>
<div class="links">
// Attempting to pass wrapper arguments here.
<%= link_to_add_association 'add derivative', f, :derivatives, {wrapper: :floating_labels_form, wrapper_mappings: {select: :floating_labels_select} } %>
</div>
</div>
</div> |
Great library! Unfortunately it appears that when using
simple_form
wrappers that cocoon doesn't correctly pick up on these wrappers when inserting new elements. I tested my problem with the demo app and replicated the problem.E.g. in the coccoon_simple_form_demo if we replace:
with a built-in
simple_form
wrapper likehorizontal_form
the first form entry will render with the correct simple_form wrappings, but subsequent entries won't. (See photo.)
The text was updated successfully, but these errors were encountered: