Comments (9)
I think you misunderstood the usage of control_group
. It isn't an alternative to fields_for
neither similar to it.
Here is an explanation of what is control_group
for Bootstrap.
I'll close this issue now but if you have any other doubt ask me!
from bootstrap_form.
I'm sorry: I didn't provide enough specificity in my issue report. I'm not calling control_group
directly. control_group
gets called via FORM_HELPERS.each{|m| define_method etc.}:
https://github.com/potenza/bootstrap_form/blob/master/lib/bootstrap_form/form_builder.rb#L24
When that chain of methods executes on a key/value pair within a serialized hash (via fields_for), your code for object.errors
throws an exception because that serialized hash item does not respond to .errors
(especially if that item is nil).
from bootstrap_form.
Let me know if you need a stack trace or full example code.
from bootstrap_form.
Hm yes, it would be nice if you create a gist with a stack trace and an example code π
from bootstrap_form.
https://gist.github.com/carlosdavis/6540470
from bootstrap_form.
Thanks. I'm taking a look at this now. I believe it may have been fixed in the 1.0 release, but I want to verify (from the stack trace, I see you're using 0.3.2).
from bootstrap_form.
Ah, thank you so much. We're on Rails 3βis the 1.0 release only for Rails 4?
from bootstrap_form.
You should be fine on 1.0 (I should note this in the README). In Rails 4, sending a block to FormBuilder.new is deprecated. To handle this, we just default the block to nil:
https://github.com/potenza/bootstrap_form/blob/master/lib/bootstrap_form/form_builder.rb#L10
I also created a Rails 3 test project with bootstrap_form 0.3.2 and was able to reproduce the error. Upgrading to 1.0 fixed it.
FYI, I had to explicitly set the text_field values to pull them from the preferences hash:
<%= bootstrap_form_for @user do |f| %>
<%= f.text_field :email %>
<%= f.fields_for :preferences do |builder| %>
<%= builder.text_field :favorite_color, value: @user.preferences[:favorite_color] %>
<%= builder.text_field :favorite_animal, value: @user.preferences[:favorite_animal] %>
<% end %>
<% end %>
If you know the keys in advance, it might be simpler to define getters/setters for the preferences keys and skip fields_for altogether.
from bootstrap_form.
I'm gonna close this for now, but let me know if you're still having issues. Thanks!
from bootstrap_form.
Related Issues (20)
- Option to provide `is-invalid` class to labels along with fields HOT 1
- Range control has wrong class HOT 5
- Release version 5.2.0 HOT 8
- Need to include ActiveRecord::Reflection for custom form class with 5.2.0 HOT 1
- Rename the default layout to "vertical" ? HOT 2
- Can't disable number_field HOT 3
- DEPRECATION WARNING: Calling `<<` to an ActiveModel::Errors message array in order to add an error is deprecated HOT 3
- [Rails 7.1] Association Validator Keyed by Association Name
- Can't edit classes on input elements. HOT 5
- Release new version (5.3.0) HOT 2
- new version 5.3.0 - undefined method `arity' for HOT 4
- V 5.3.1 - Using ruby's %w() array shortcut in bootstrap_form_for statement causes 'ActionView::Template::Error:' HOT 6
- Generate System Test Baseline via GitHub Actions
- Some Examples May Be Failing
- `collection_check_boxes` does not work with Rails 6.1 HOT 3
- Lazy load ActionText helpers HOT 10
- Overriding form tag's 'control_col' not working for f.check_box (layout: :horizontal)
- Need to use plain method for visibility with bootstrap_form in Phlex Component HOT 2
- render problem HOT 3
- Update Gemfiles?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bootstrap_form.