Comments (6)
@galulex where is this in the bootstrap docs?
Show me and i will take a look to implement it.
from bootstrap_form.
@carloslopes Until this past week, I had never used fields_for in any of my projects with this Gem. However, this week I used it for a nested association and ran into an problem that took me a while to figure out. I'm wondering if @galulex ran into the same issue. Here it is:
Say you have a user with a has_one association with an address model. If you do this:
bootstrap_form_for(@user) do |f|
f.fields_for :address do |af|
af.text_field(:street)
end
end
AND you don't have accepts_nested_attributes_for :address
set on the user model, you'll get an exception that looks something like this:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.errors
/Users/potenza/Sites/bootstrap_form/lib/bootstrap_form/form_builder.rb:69:in `control_group'
/Users/potenza/Sites/bootstrap_form/lib/bootstrap_form/form_builder.rb:24:in `block (2 levels) in <class:FormBuilder>'
...
I'll commit a test case for this functionality shortly...
from bootstrap_form.
lol, i forgot the rails' fields_for
helper and i was thinking that it was something of the bootstrap framework
@potenza why did you use form_for
on the test case? I updated the it to use bootstrap_form_for
instead.
from bootstrap_form.
@carloslopes Oops! Stupid cut and paste error on my part. Thanks for catching that
from bootstrap_form.
@galulex I'm gonna close this issue for now, but please let us know if you're running into a different issue with fields_for
.
from bootstrap_form.
Thanks guys. Well done
from bootstrap_form.
Related Issues (20)
- If an input is required then the input does nog always get the required element
- Extra spaces added in tests
- Test Fail on Edge AKA Rails 7 HOT 3
- Investigate Rails 7 Tests/Config Needing `sassc` HOT 1
- text_field options hide_label and label_as_placeholder not working HOT 4
- Danger via GitHub Actions Fails when Pull Request is from a Fork HOT 6
- Floating labels don't work inside input groups (prepend/append) HOT 16
- scaffold template and more HOT 2
- Possible Unsafe String Interpolation HOT 2
- Error messages don't display on form_group HOT 2
- inline validation for fields_for HOT 2
- `join` May Cause Unwanted HTML Escapes HOT 4
- Set required and aria on input when input is required HOT 1
- I can't Disable select field HOT 2
- What is the coorect way to make i18n translations for labels? HOT 2
- Tests May Not Be Good Enough
- 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
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.