UPDATE: Good news! Actualy SimpleForm 2.0.3 was released with a bunch of bugfixes and small features that are described below. Full CHANGELOG is here.
Hey, readers! Today I want to share with you some news about upcoming SimpleForm 2.1.0 release. A lot of bugs were fixed and some awesome features were added. So let’s take a look on these goodies:
1. :checked option
Now you can pass an array to :checked
option and these values will be checked:
1
|
|
Just wow, right?
2. nil :collection
Imagine you have such code:
1 2 3 |
|
So if @documents
is a nil
object then all documents will be loaded. Looks like a security hole, right? Not anymore. In SimpleForm 2.1.0 f.association
creates blank select for blank association. That’s right, mind = blown.
3. config.generate_additional_classes_for
Guys, guys, guys! With new SimpleForm form you can add all these additional CSS classes (like string
for string inputs, text
for text inputs, etc.) only for wrapper! I can’t believe in this but it’s a pure truth! All you need is to set up config.generate_additional_classes_for
with [:wrapper]
option:
config/initializers/simple_form.rb:
1
|
|
4. checked_value and unchecked_value
Oh. My. God. With new SimpleForm you can specify checked and unchecked values for boolean inputs:
1
|
|
And now instead of default 1
for checked value and 0
for unchecked you’ll get on
and off
. Unbelievable. I was dreaming about it soooooo long.
5. config.wrapper_mappings
And last but not least. Make sure you’re sitting right now. Hey, you, I’m not kidding, take a sit because this last awesome feature will turn your world upside down.
You can specify different wrappers for different input types in your SimpleForm’s config! Take a look at this example below:
config/initializers/simple_form.rb:
1
|
|
BOOM! All your string inputs uses :prepend
wrapper. Crazy, right?! Just think about it. You can specify different wrappers for different input types in your SimpleForm’s config. WOOOOW!
Yeah, this 2.1.0 version is not released yet but you always can try it from git:
1
|
|
You can read full CHANGELOG here
Phew, that’s all. I hope you like it. Cheers!