Open
Description
BootstrapForm::Aliasing
needs to go. There's a reason why Rails ditched this meta-programming hackiness.
The thing is, you can live without it. Observe:
<%= bootstrap_form_for @user do |form| %>
<%= form.text_field :misc %>
<%= fields_for @user do |unformatted_form| %>
<%= unformatted_form.text_field :misc %>
<% end %>
<% end %>
All you need to do is wrap fields you don't want to be formatted in fields_for
(fields_with
behave the same). Resulting HTML currently looks like this:
<form>
<div class="form-group">
<label for="user_misc">
Misc
</label>
<input class="form-control" type="text" name="user[misc]" id="user_misc" />
</div>
<input type="text" name="user[misc]" id="user_misc" />
</form>
This is a documented Rails thing and anybody who ever worked with forms should be aware what fields_for
can do. Also you can pass your own :builder
option into it as well.
This will remove a lot of needless code.
For convenience sake I'm not against introducing option into form helper to bypass bootstrap wrappers as per @jeffblake as it's literally a single line addition.
define_method(method_name) do |name, options = {}|
return super(name, options) if options[:super]
form_group_builder(name, options) do
prepend_and_append_input(options) do
super name, options
end
end
end