bullet_train
bullet_train copied to clipboard
Proposal to add number_field support for Field Partials
Pretty new to Bullet Train, so doing a lot of reading, exploring, and generally just trying to figure things out.
In the app I'm trying to build with Bullet Train, I wanted to have some input fields that are purely numeric in nature (ie: ). Since Rails has a number_field
form helper, this seemed like it should be pretty simple, but according to the Field Partials Documentation, this input type doesn't seem to be supported.
I dug around deep enough to find a couple of places in the various bullet_train gems where I would need to update the code to try and add this new functionality:
- bullet_train-super_scaffolding:
- lib/scaffolding.rb : add
number_field
to thevalid_attribute_type?
definition - lib/scaffolding/transformer.rb : add a
number_field
case that returnsnumber
in theadd_attributes_to_various_views
method definition
- bullet_train-themes: added a file (app/views/themes/base/fields/_number_field.html.erb) that at present is just a pure copy of the _text_field.html.erb file in the same directory.
This is the point at which my lack of knowledge regarding the structure of BT strikes again. I'm getting an error when I try to hit the site at this point (see screenshot below), but I'm already out of ideas on where to look next in order to implement this input type.

Would appreciate any help/guidance I can get here.
Hey @esmale, thanks for working on this, I'm excited to see it come together! It seems like you're on the right track, so I'm curious if it has to do with bullet_train-themes
since that gem is linked via bullet_train-themes-light
. Your main app might not be picking up on the partial if it's not being installed via the Gemfile correctly. I usually just add it manually in the Gemfile under bullet_train-themes-light
just to check the changes there:
gem "bullet_train-themes", path: "./local/bullet_train-themes"
It's hard to say without the full context of the app though, so if you're cool with it, you could open a couple of PRs over at bullet_train-super_scaffolding
and bullet_train-themes
and I'd love to work through it with you (although I'm sure @andrewculver would have the best input). I like the number_field
idea and would be glad to see your work merged in!
Other things to consider
The case statement you're talking about is referring to attribute partials, so I think you'll need one more partial named _number.html.erb
in the attributes
directory. It's also probably important to note that we currently handle integers as strings, so we'll most likely need to account for this line when adding the code.
This was fixed in https://github.com/bullet-train-co/bullet_train-core/pull/32