Comments (10)
I too would like to see this addition.
from bootstrap_form.
At first, thanks for great gem!
At second, one question:
If bootstrap_form_tag allows me to use it instead of?
<%= form_tag produce_recipe_path, method: :post, class: "form-inline" do %>
<%= text_field_tag :count %>
<%= submit_tag "Produce", class: "btn btn-success btn-sm" %>
<% end %>
Then i wait for bootstrap_form_tag too. Or you know another method for custom actions in bootstrap?
from bootstrap_form.
@oblaka yes, bootstrap_form_tag
would allow you to do that.
This is really a useful feature, but there are some things that should be discussed before we do any work on it.
Today, we know which type of form the user want checking the options passed to bootstrap_form_for
method (example: bootstrap_form_for @user, style: :horizontal
)
With a bootstrap_form_tag
we wouldn't have a relation between the form and the elements, so, how could we know which type of control should be rendered? horizontal or inline?
from bootstrap_form.
Maybe it's possible to make it similar bootstrap_form_for way?
For example,
<%= bootstrap_form_tag( controller: 'recipe', action: 'produce', method: :post, style: :inline) do |f| %>
<%= f.text_field :count %>
<%= f.submit "Produce", class: :success %>
<% end %>
or add 'f.form_group' around elements (if elements should be rendered in non-default control type)?
from bootstrap_form.
One method for getting some of this functionality is in pull request #70. I'm not sure that is the direction to take, but it might help in the discussion.
from bootstrap_form.
Thanks, man! How about add validations functionality?
Anonymous models haven't owns, so next step is define place for it. What do you think?
from bootstrap_form.
I added the PR but, in practice, pretty much the only time I would ever use it is if I was submitting to a site outside of my application with very different field conventions. In most other cases, whether the form is AR-backed or not, I am going to use a form object. Rails 4 makes it pretty trivial to create form objects that you can use with form_for rather than form_tag.
The example above could be used with form_for with just this...
class ProduceRecipeForm
include ActiveModel::Model
attr_accessor :count
end
<%= bootstrap_form_for :produce_recipe_form, url: produce_recipe_path do |f| %>
<%= f.text_field :count %>
<%= f.primary "Produce"
<% end %>
Validations can be added to the ProduceRecipeForm in the same manner as they are in models inheriting from ActiveRecord...
validates :count, presence: true
from bootstrap_form.
I create form as you suggested, it works, but validations still not working. Could you see on commit, maybe i do it wrong? sovetnik/cooker@c59e2ec
from bootstrap_form.
closed with #70
from bootstrap_form.
@oblaka - This article will probably help you in getting your form working... http://robots.thoughtbot.com/activemodel-form-objects
Basically, you'll need to kick off the validation in your create action.
from bootstrap_form.
Related Issues (20)
- 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
- Rename the default layout to "vertical" ? HOT 2
- Can't disable number_field HOT 3
- DEPRECATION WARNING: Calling `<<` to an ActiveModel::Errors message array in order to add an error is deprecated HOT 3
- [Rails 7.1] Association Validator Keyed by Association Name
- Can't edit classes on input elements. HOT 5
- Release new version (5.3.0) HOT 2
- new version 5.3.0 - undefined method `arity' for HOT 4
- V 5.3.1 - Using ruby's %w() array shortcut in bootstrap_form_for statement causes 'ActionView::Template::Error:' HOT 6
- Generate System Test Baseline via GitHub Actions
- Some Examples May Be Failing
- `collection_check_boxes` does not work with Rails 6.1 HOT 3
- Lazy load ActionText helpers HOT 10
- Overriding form tag's 'control_col' not working for f.check_box (layout: :horizontal)
- Need to use plain method for visibility with bootstrap_form in Phlex Component HOT 2
- render problem HOT 3
- Update Gemfiles?
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.