mjbellantoni / formtastic-bootstrap Goto Github PK
View Code? Open in Web Editor NEWFormtastic form builder to generate Twitter Bootstrap-friendly markup.
License: MIT License
Formtastic form builder to generate Twitter Bootstrap-friendly markup.
License: MIT License
Hey Guys,
Just updated to rails 4 a kind of old app (1 year-ish) and when I try to render my views I get this:
ActionView::Template::Error (The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option?):
3:
4:
5:
I feel like i'm doing something very stupid since I haven't found anything about it on the web. Anyone seen such error?
I'm using ruby 2.0.0p247 and rails 4.0.2
Thank you!
Based on Twitter Bootstrap documentation, inline errors and other inline help elements should be placed inside the controls class:
<div class="control-group">
<label class="control-label" for="foo">Foo</label>
<div class="controls">
<input type="text" id="foo">
<span class="help-inline">Username is taken</span>
</div>
</div>
Formtastic-bootstrap puts them outside the controls class, like this:
<div class="control-group">
<label class="control-label" for="foo">Foo</label>
<div class="controls">
<input type="text" id="foo" />
</div>
<span class="help-inline">can't be blank</span>
</div>
Here's a screenshot what happens when using horizontal forms:
Using Formtastic-bootstrap: 1.1.2
Using Formtastic 2.0.2
I'm getting an issue when using formtastic-bootstrap with rails3-jquery-autocomplete. For reference: crowdint/rails3-jquery-autocomplete#128. The issue occurs when using:
f.input :something :as => :autocomplete, :url => "some path"
Removing formastic.rb from config/initializers allows the page to render correctly(without the gem's styling) and the autocomplete functionality to work. Any ideas?
Trace
formtastic (2.0.2) lib/formtastic/helpers/input_helper.rb:353:in
rescue in input_class'
formtastic (2.0.2) lib/formtastic/helpers/input_helper.rb:345:in input_class' formtastic (2.0.2) lib/formtastic/helpers/input_helper.rb:265:in
input'`
Formtastic detects when a model has something like validates :name, :presence => true and adds a required attribute to the relevant input field. With your bootstrap modifications it adds a required class to the control-group div but not a required attribute to the input field which means jquery.validate doesn't work. You can make it add the attribute with input_html: { required: true }
A small suggestion:
Currently, formtastic-bootstrap defaults to help-inline as the class for hints.
I have an application with some very long hint texts. Those look terrible with help-inline, so I use help-block instead.
In the form examples at http://twitter.github.com/bootstrap/#forms help-block seems to be the preferred class as well.
So maybe it might make sense to change the default in formtastic-bootstrap to help-block. In any way it would be nice to add instructions to the README how to configure this globally.
Adding classes to submit or button fails.
<%= f.submit , :class=>"btn btn-success" %>
<%= f.submit , :input_html=>"btn btn-success" %>
<%= f.button, :class=>"btn btn-success" %>
Hi!
I am the maintainer of three gems similar to this one that make it easier to use Twitter Bootstrap in Ruby projects (https://github.com/krautcomputing/rails-bootstrap-navbar, https://github.com/krautcomputing/bootstrap-navbar, https://github.com/krautcomputing/middleman-bootstrap-navbar).
I was thinking about moving all those gems to a separate organisation (like "bootstrap-ruby") and wanted to get some feedback from other maintainers of similar gems (and the community at large) if that makes sense and if we could use this to make it easier for people to find gems to work with Bootstrap in Ruby (Rails, Sinatra, etc.)
I think it would also invite other people to contribute to those projects if they were united in a central organisation.
What do you think?
Would you be willing to move this repo to such an organisation as well?
Matthew, would any of the contributors be willing to take over merge and release duties? It'd be really awesome if someone would step up with a supported fork, and release their gems to the canonical https://rubygems.org/gems/formtastic-bootstrap
After installing formtastic-bootstrap according to the readme (gem, css, initializer) I get an error with the following code
<%= semantic_form_for current_user do |f| %>
<%= f.input :end_time %>
<% end %>
user.end_time is a DateTime. It does something weird with fragment_placeholder for the string 'year'. I should also note that I am on Rails 4 (beta 1) and ruby 2.0.0-p0.
04:46:52 log.1 | TypeError - no implicit conversion of nil into String:
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:49:in `fragment_placeholder'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:33:in `block in fragment_input_html_options'
04:46:52 log.1 | (gem) andand-1.3.3/lib/andand.rb:60:in `me'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:30:in `fragment_input_html_options'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:26:in `fragment_input_html'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:12:in `block (3 levels) in to_html'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:11:in `block (2 levels) in to_html'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:38:in `capture'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/wrapping.rb:31:in `controls_wrapping'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:9:in `block in to_html'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:38:in `capture'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/wrapping.rb:25:in `control_group_wrapping'
04:46:52 log.1 | (gem) formtastic-bootstrap-2.0.0/lib/formtastic-bootstrap/inputs/base/timeish.rb:7:in `to_html'
04:46:52 log.1 | (gem) formtastic-2.2.1/lib/formtastic/helpers/input_helper.rb:240:in `input'
04:46:52 log.1 | app/views/users/show.html.erb:6:in `block in _app_views_users_show_html_erb__1818619761525654053_70131809307920'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/capture_helper.rb:38:in `capture'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/helpers/form_helper.rb:435:in `form_for'
04:46:52 log.1 | (gem) formtastic-2.2.1/lib/formtastic/helpers/form_helper.rb:161:in `block in semantic_form_for'
04:46:52 log.1 | (gem) formtastic-2.2.1/lib/formtastic/helpers/form_helper.rb:192:in `with_custom_field_error_proc'
04:46:52 log.1 | (gem) formtastic-2.2.1/lib/formtastic/helpers/form_helper.rb:160:in `semantic_form_for'
04:46:52 log.1 | app/views/users/show.html.erb:5:in `_app_views_users_show_html_erb__1818619761525654053_70131809307920'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/template.rb:143:in `block in render'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications.rb:160:in `instrument'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/template.rb:141:in `render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/abstract_renderer.rb:23:in `block in instrument'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications.rb:158:in `block in instrument'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications.rb:158:in `instrument'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/abstract_renderer.rb:23:in `instrument'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/template_renderer.rb:17:in `render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/renderer.rb:36:in `render_template'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_view/renderer/renderer.rb:17:in `render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/rendering.rb:119:in `_render_template'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/streaming.rb:219:in `_render_template'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/rendering.rb:112:in `render_to_body'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/rendering.rb:97:in `render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/rendering.rb:16:in `render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
04:46:52 log.1 | /Users/vincentwoo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/core_ext/benchmark.rb:5:in `ms'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
04:46:52 log.1 | (gem) activerecord-4.0.0.beta1/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb:40:in `render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/base.rb:189:in `process_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/rendering.rb:10:in `process_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/callbacks.rb:383:in `_run__878521350067367672__process_action__callbacks'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/callbacks.rb:78:in `run_callbacks'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/callbacks.rb:17:in `process_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/rescue.rb:29:in `process_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications.rb:158:in `block in instrument'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/notifications.rb:158:in `instrument'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
04:46:52 log.1 | (gem) activerecord-4.0.0.beta1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/base.rb:136:in `process'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/abstract_controller/rendering.rb:44:in `process'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal.rb:196:in `dispatch'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_controller/metal.rb:232:in `block in action'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb:78:in `dispatch'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb:46:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/journey/router.rb:69:in `block in call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/journey/router.rb:57:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/routing/route_set.rb:651:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/etag.rb:23:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/head.rb:11:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/flash.rb:241:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/cookies.rb:452:in `call'
04:46:52 log.1 | (gem) activerecord-4.0.0.beta1/lib/active_record/query_cache.rb:36:in `call'
04:46:52 log.1 | (gem) activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:632:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/callbacks.rb:373:in `_run__3051430443707796577__call__callbacks'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/callbacks.rb:78:in `run_callbacks'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/reloader.rb:64:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
04:46:52 log.1 | (gem) better_errors-0.7.2/lib/better_errors/middleware.rb:84:in `protected_app_call'
04:46:52 log.1 | (gem) better_errors-0.7.2/lib/better_errors/middleware.rb:79:in `better_errors_call'
04:46:52 log.1 | (gem) better_errors-0.7.2/lib/better_errors/middleware.rb:56:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
04:46:52 log.1 | (gem) railties-4.0.0.beta1/lib/rails/rack/logger.rb:38:in `call_app'
04:46:52 log.1 | (gem) railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `block in call'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `block in tagged'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:25:in `tagged'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `tagged'
04:46:52 log.1 | (gem) railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `call'
04:46:52 log.1 | (gem) quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/runtime.rb:17:in `call'
04:46:52 log.1 | (gem) activesupport-4.0.0.beta1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/lock.rb:17:in `call'
04:46:52 log.1 | (gem) actionpack-4.0.0.beta1/lib/action_dispatch/middleware/static.rb:64:in `call'
04:46:52 log.1 | (gem) railties-4.0.0.beta1/lib/rails/engine.rb:510:in `call'
04:46:52 log.1 | (gem) railties-4.0.0.beta1/lib/rails/application.rb:96:in `call'
04:46:52 log.1 | (gem) railties-4.0.0.beta1/lib/rails/railtie/configurable.rb:30:in `method_missing'
04:46:52 log.1 | (gem) rack-1.5.2/lib/rack/deflater.rb:25:in `call'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/connection.rb:81:in `block in pre_process'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/connection.rb:79:in `pre_process'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/connection.rb:54:in `process'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/connection.rb:39:in `receive_data'
04:46:52 log.1 | (gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/backends/base.rb:63:in `start'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/server.rb:159:in `start'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/controllers/controller.rb:86:in `start'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/runner.rb:187:in `run_command'
04:46:52 log.1 | (gem) thin-1.5.0/lib/thin/runner.rb:152:in `run!'
04:46:52 log.1 | (gem) thin-1.5.0/bin/thin:6:in `<top (required)>'
04:46:52 log.1 | /Users/vincentwoo/.rvm/gems/ruby-2.0.0-p0/bin/thin:23:in `<main>'
04:46:52 log.1 | /Users/vincentwoo/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
When I include the Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder line to my initializers, I get the following error:
Completed 500 Internal Server Error in 1968ms
ActionView::Template::Error (end of file reached)
Rendered /Users/joerg/.rvm/gems/ruby-1.9.3-p0@app/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (6.4ms)
When you use a prepend text the hint-block span has been added inside the prepend div just like this
<div class="controls">
<div class="input-prepend">
<span class="add-on" ...>
<input ..>
<span class="help-block"> ... </span>
</div>
</div>
But from what I understood the hint block should be outside the input prepend otherwise the font-size won't be properly setted.
<div class="controls">
<div class="input-prepend">
<span class="add-on" ...>
<input ..>
</div>
<span class="help-block"> ... </span>
</span>
This code does not render any errors as f.semantic_errors
is nil
. Calling f.semantic_errors :base
is also nil
.
= semantic_form_for @client, :url => admin_clients_path, :html => { :class => "form-horizontal" } do |f|
.row
.span3.pull-right
= f.semantic_errors
.span7
= f.inputs "Client" do
= f.input :name
= f.inputs "Address" do
= f.input :address_line_1
= f.input :address_line_2
= f.input :city
= f.input :state
= f.input :zip_code
= f.inputs "Public Contact Info" do
= f.input :email, :as => :email
= f.input :website, :as => :url
= f.input :phone, :as => :phone
= f.input :fax, :as => :phone
= f.actions
Changing the line to the following will generate and render an error if applicable for the given field:
= f.semantic_errors :name
I'm using rails 4.0.0.beta1.
= semantic_form_for @resource do |f|
= f.semantic_errors :resource
= f.inputs do
= f.input :uid, label: "UID"
= f.input :system, label: "System", as: :boolean
= f.actions do
= f.action :submit, as: :input, label: "Submit"
= f.action :cancel, as: :link, label: "Cancel"
The 'system' input, a boolean, causes this error:
undefined method `check_box_checked?' for ActionView::Helpers::InstanceTag:Class
The issue got mentioned at Don't use ActionView::Helpers::InstanceTag.check_box_checked? anymore and the fix is here: bluerail/formtastic@71a3bd2, in the rails4beta branch.
So, it seems like a rails4beta branch here would make sense. Has anyone started? I don't foresee big changes; formtastic-bootstrap could just depend on the formtastic rails4beta branch.
Everything apparently works fine, but I am not able to show inline error messages on my forms.
Disabling the formtastic-bootstrap, I could achieve the expected ugly result.
Using
I've installed the gem, set the initialiser code, changed application.css, and... Nothing happens. The generated form has exactly the same structure, even down to labels, fieldsets and date select fields which the docs say would be different in formtastic-bootstrap.
I'm using;-
rvm ruby 2.0.0-p247
Rails 4.0.1
gem 'sass-rails', '> 4.0.0'> 3.0.3.0'
gem 'bootstrap-sass', '
gem "formtastic", "~> 2.3.0.rc2"
gem 'formtastic-bootstrap'
in config/initializers/formtastic.rb I have;-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
in app/assets/stylesheets/application.css I have;-
*= require formtastic-bootstrap
What's the secret incantation required to get it working?
doesn't play nice with latest bootstrap and formtastic. any update?
All parent inputs has twitter bootstrap markup, but semantic_fields_for inputs has old style markup with <li>
and <ol>
Scenario:
Given a field that has errors
When I display the field within an input type as :check_boxes and configuring to display errors inline - I expect to the the error string below that field.
With formtastic-bootstrap (3.0.0) that is not the case. I do not see the error message.
I do have a proposed fix for this and can send a pull request, but I'd like to verify that my fix does not break anything. However, I can't seem to get specs to run properly given my recently forked clone.
Can someone provide guidance on how to get the test suite to run?
Current suite fails with:
uninitialized constant Rails::VERSION (NameError)
Attempts to fix this just cause more issues.
Formtastic 2.2+ API has replaced the "buttons" FormBuilder instance method with an "actions" method, so the example code in the README is now out-of-date/broken. I was going to fork and make a pull request but it hardly seems worth it for one-line change to the docs, so this is just a heads up that "f.buttons do " is now "f.actions do "
Trying to use a base install of this gem. And I can't get a basic form to pump out because of the error in the subject (this is from current revisions to RC's and the reference here is using EDGE from GIT. I've actually read and completed installation, then executed rails g formtastic:form Project Here are some more details.
ActionView::Template::Error (wrong number of arguments (5 for 4)):
1: = semantic_form_for @project do |f|
2: = f.inputs do
3: = f.input :title
4: = f.input :season
app/views/projects/_form.html.slim:1:in _app_views_projects__form_html_slim__530644245_16062828' app/views/projects/new.html.slim:5:in
_app_views_projects_new_html_slim___785148024_45285240'
Gemfile.lock
GIT
remote: git://github.com/justinfrench/formtastic.git
revision: c79e46560d1516c6c3c0ef85fb29bed8e36068ac
specs:
formtastic (2.3.0.rc3)
actionpack (>= 3.2.13)
GIT
remote: git://github.com/mjbellantoni/formtastic-bootstrap.git
revision: ee1bd16
specs:
formtastic-bootstrap (3.0.0)
formtastic (>= 2.2)
The current gemspec allows formtastic-bootstrap to be installed with formtastic 3.0.0.
This breaks the :input
form element (and maybe others), because formtastic dropped ::GroupedCollections
, which is included by ::SelectInput
.
So it would be nice if this was fixed, but in the meantime, setting the dependency to not allow 3.0.0 would be very useful (this issue is kind of hard to find, because rails seems to swallow the underlying exception).
What is the general strategy for Datetime and Date etc. The readme mentions a standalone gem.
:datetime, :date, :time
As rich functionally as their Rails counterparts.
Extract into a standalone gem.
I ask because I looking to create a set of Credit Card inputs and I'm curious how you were planing to package the gem
The automatic hidden field that Rails usually includes when it renders a checkbox, so that when the checkbox gets unchecked it would sumbit the zero value is not rendered.
When I try to add date text field to my formtastic-bootstrap form:
= form.input :start_on
I get the following error:
undefined method `text_field_date' for #<#<Class:0x007f8153f03990>:0x007f8153efd888>
The following doesn't work:
f.input :date_of_birth, input_html: { class: "ui-datepicker" }
Other attributes, like value
can be placed into the input_html
hash and are changed just fine. Additionally the class
attribute can be altered for other inputs with no problems. However, they are ignored for dates. I know that date handling is not fully complete so this might be by design rather than a bug but, in that case, it might be useful to mention that in the README.
Current workaround:
f.input :date_of_birth, as: :string, input_html: { class: "ui-datepicker" }
057f708 causes the specs to halt (not just fail).
$ bundle exec rake spec
formtastic-bootstrap/lib/formtastic-bootstrap/form_builder.rb:34:in `<class:FormBuilder>': uninitialized constant FormtasticBootstrap::Helpers::ErrorsHelper (NameError)
from /Users/david/src/formtastic-bootstrap/lib/formtastic-bootstrap/form_builder.rb:3:in `<module:FormtasticBootstrap>'
from /Users/david/src/formtastic-bootstrap/lib/formtastic-bootstrap/form_builder.rb:1:in `<top (required)>'
from /Users/david/src/formtastic-bootstrap/lib/formtastic-bootstrap.rb:4:in `<top (required)>'
When using f.semantic_fields_for and a :time attribute there is no name attibute in that input.
Example:
<%= f.semantic_fields_for :schedules do |schedule| %>
<%= render :partial => 'schedule_fields', :locals => { :f => schedule} %>
<% end %>
in my partial:
<%= f.input :start , :as => :time %>
the result is a input with no name
When creating a new form, and using the :wrapper_html param, the 2.0.0 version of this gem does not work as expected. In fact, the whole param is completely ignored.
This problem is related to this gem, in fact if I remove the initializer call from the stack, the formtastic gem works as expected.
I also noticed that those fields that are marked as hidden are always being shown.
I tried using the default formtastic (formtastic-2.2.0) and kept getting a generic load error:
/Users/eric/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require': cannot load such file -- formtastic/bootstrap (LoadError)
When I locked it to 2.0.2 it worked fine.
-Eric
Figured it's worth having a discussion about Bootstrap 3 plans. I just started a Bootstrap 3 project today and see that my beloved FormtasticBootstrap::FormBuilder doesn't play so nice. The markup's changed pretty significantly (http://getbootstrap.com/css/#forms). I may hack a little to try and get the essential inputs to play nice just for myself but between work commitments and a trip I'm going on next week it would not be smart for me to make a real commitment. Was just curious if anyone has been working on this?
I get the below error message when installing formstatic-bootstrap.
Error installing formtastic-bootstrap: formtastic-bootstrap requires formtastic-bootstrap (>= 0).
Can someone help me solving the issue?
For some reason f.buttons, f.buttons :commit, don't output the actual buttons, working around by using f.commit_button at the moment.
Hello, I have a rails application and I'm using jruby-1.6.6.
I've put in config/initializers/formtastic.rb
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
Then I create the war file and put under tomcat but when I run the application it says:
uninitialized constant FormtasticBootstrap.
It's critical from me because if I use formtastic bootstrap I can't run my applications.
The same problem if I run rake db:migration RAILS_ENV="production"
can you also support nested_form made by Ryan Bates which is based on formtastic? I think it is very widely used and people would love to see this support.
After cloning the repo and bundling, I get the following error when running the specs:
/Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-rails-2.14.2/lib/rspec/rails/adapters.rb:7:in `<module:Rails>': uninitialized constant Rails::VERSION (NameError)
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-rails-2.14.2/lib/rspec/rails/adapters.rb:6:in `<module:RSpec>'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-rails-2.14.2/lib/rspec/rails/adapters.rb:5:in `<top (required)>'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ammeter-0.2.9/lib/ammeter/rspec/generator/example/generator_example_group.rb:3:in `require'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ammeter-0.2.9/lib/ammeter/rspec/generator/example/generator_example_group.rb:3:in `<top (required)>'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ammeter-0.2.9/lib/ammeter/rspec/generator/example.rb:2:in `require'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ammeter-0.2.9/lib/ammeter/rspec/generator/example.rb:2:in `<top (required)>'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ammeter-0.2.9/lib/ammeter/init.rb:1:in `require'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/ammeter-0.2.9/lib/ammeter/init.rb:1:in `<top (required)>'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/formtastic-2.2.1/spec/spec_helper.rb:13:in `require'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/formtastic-2.2.1/spec/spec_helper.rb:13:in `<top (required)>'
from /Users/david/code/ruby/formtastic-bootstrap/spec/spec_helper.rb:12:in `require'
from /Users/david/code/ruby/formtastic-bootstrap/spec/spec_helper.rb:12:in `<top (required)>'
from /Users/david/code/ruby/formtastic-bootstrap/spec/actions/button_action_spec.rb:2:in `require'
from /Users/david/code/ruby/formtastic-bootstrap/spec/actions/button_action_spec.rb:2:in `<top (required)>'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `each'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:22:in `run'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /Users/david/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
This looks like it might be related to the following bug/PR on ammeter: alexrothenberg/ammeter#22
Has anyone had success running the specs recently?
Hi,
I had a hard time to to get active_enum
working with formtastic-bootstrap
.
I've now created a patch for active_enum
. Can someone here please have
have a look at it. I wonder whether it is the right way to fix it. Thanks!
Hi there,
I just installed your gem and it is causing an error with my Rails project. The error I am getting is:
/Users/jmaskell/.rvm/gems/ruby-1.9.2-p290@rails3/gems/formtastic-bootstrap-1.0.3/lib/formtastic-bootstrap/helpers/buttons_helper.rb:5:in `<module:ButtonsHelper>': uninitialized constant Formtastic::Helpers (NameError)
This happens when I try to boot the Rails server. I'm using the latest versions of twitter-bootstrap, formtastic and formtastic-bootstrap.
Form structure, classes, etc. are changing in the coming 2.0 version of Bootstrap.
Just wanting to put this on your radar as the new release gets closer.
Hoping I'll find time to contribute and help with the transition...
Scenario:
Multiple instances of a form rendered on a single page.
Bug:
Clicking a label will trigger a checkbox in the wrong form.
(I have this problem in Chrome 32.0.1700.102, Linux and QtWebkit)
My solution for now is removing the "for" attribute in labels via javascript. But this is IMHO kinda ugly... :-/
In my opinion the "for"-attribute is not really needed since the input element is wrapped in the label-tag. Clicking on a parent label will propagate the click to the child input element and everything works fine.
Since the "for"-attribute is not required and the behaviour for labels with their corresponding input element wrapped inside is well defined (1) I think the best solution would be to just ommit the attribute in this case.
Anyone using this with bootstrap's "horizontal" form style (class .form-horizontal
)?
Since the html structure and styles seem to be quite different (the .control-group
, .control-label
, and .controls
styles), seems this requires some changes to formtastic-bootstrap and can't be accomplished with it "out of the box"? Or am I missing something obvious?
Looking at the code to see how much effort this would be, but I'm not sure I have the bandwidth to take it on at the moment.
The latest build of formtastic-bootstrap does not include files in the lib directory.
What about supporting input as :text?
I tried but generated HTML was indentical to :string type. Bootstrap use specialized css classes for hints and the textarea.
trying to use rails 3.2 with twitter bootstrap and formtastic-bootstrap - works nicely if you use the manifest at the top of application.css but I need to use @import so I can override the $vars. When I use @import the files appear to be there in the browser but no styles apply. can't see what I am doing wrong - is this an issue?
this is what I have in application.css after the manifest
@import 'twitter/bootstrap';
@import 'formtastic-bootstrap.css';
The gem dependency rails ~> 3.1.0
means that I can't use formtastic-bootstrap with the new rc. Perhaps change it to rails ~> 3.1
?
country_select version 2.0.0 (not yet released) introduces a number of big changes. One among them is a different syntax for country_select
view helper:
def country_select(method, options = {}, html_options = {})
(source)
Which is incompatible with formtastic-bootstrap's invocation:
builder.country_select(method, priority_countries, input_options, input_html_options)
(source)
The exact same issue is present on latest formtastic
gem as well: formtastic/formtastic#1008
This is happening because of: https://github.com/mjbellantoni/formtastic-bootstrap/blob/master/lib/formtastic-bootstrap/inputs/base/timeish.rb#L49
I'm pretty sure this is unintended behavior, and I think the placeholder should be specifiable, or otherwise default to something more meaningful.
Per formatsitc-bootstrap readme:
<%= semantic_form_for @client do |f| %>
<%= f.inputs do %>
<%=f.input :login %>
<%=f.input :display_name %>
<%end%>
<%= f.actions do %>
<%= f.action :submit %>
<% end %>
<% end %>
when I look at this form, the submit button isn't styled correctly.
the html is:
<fieldset class="form-actions">
<input class="btn" name="commit" type="submit" value="Update Client">
</fieldset>
Per bootstraps documentation:
"typically you'll want to apply these to only and elements for the best rendering."
shouldn't it be this instead?
<fieldset class="form-actions">
<button class="btn" name="commit" type="submit" >Update Client</button>
</fieldset>
Am I using it wrong?
are you still maintaining this project? would be nice to pass it off to someone that will maintain it instead of the forks that are popping up everywhere for bootstrap 2 and formtastic 2.2 etc.
Has anyone done this? I was thinking of using the css :before and :after for it. Any cleaner solution?
Just once would be nice
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.